|
| 1 | +# Configuration & Authentication Audit |
| 2 | + |
| 3 | +## Current State Analysis |
| 4 | + |
| 5 | +### Authentication Methods Priority Order |
| 6 | + |
| 7 | +1. **Command-line flags** (highest priority) |
| 8 | + - `--profile <name>` - Use specific profile |
| 9 | + - `--deployment <cloud|enterprise>` - Force deployment type |
| 10 | + |
| 11 | +2. **Environment Variables** (second priority) |
| 12 | + - `REDISCTL_PROFILE` - Default profile name |
| 13 | + - Cloud-specific: |
| 14 | + - `REDIS_CLOUD_API_KEY` - API key |
| 15 | + - `REDIS_CLOUD_API_SECRET` - API secret |
| 16 | + - `REDIS_CLOUD_API_URL` - Custom API URL (optional) |
| 17 | + - Enterprise-specific: |
| 18 | + - `REDIS_ENTERPRISE_URL` - Cluster URL |
| 19 | + - `REDIS_ENTERPRISE_USER` - Username |
| 20 | + - `REDIS_ENTERPRISE_PASSWORD` - Password |
| 21 | + - `REDIS_ENTERPRISE_INSECURE` - Allow insecure TLS (true/false) |
| 22 | + |
| 23 | +3. **Profile Configuration** (third priority) |
| 24 | + - Location varies by OS: |
| 25 | + - Linux: `~/.config/redisctl/config.toml` |
| 26 | + - macOS: `~/Library/Application Support/com.redis.redisctl/config.toml` |
| 27 | + - Windows: `%APPDATA%\redis\redisctl\config.toml` |
| 28 | + - TOML format with profiles section |
| 29 | + |
| 30 | +4. **Default Profile** (lowest priority) |
| 31 | + - Set via `redisctl profile default <name>` |
| 32 | + - Stored in config file |
| 33 | + |
| 34 | +### Current Pain Points |
| 35 | + |
| 36 | +1. **Discovery Issues** |
| 37 | + - Users don't know where config file is stored |
| 38 | + - No way to print config file location |
| 39 | + - No command to show current active configuration |
| 40 | + |
| 41 | +2. **Setup Complexity** |
| 42 | + - No guided setup for first-time users |
| 43 | + - Manual profile creation requires knowing all fields |
| 44 | + - No validation during setup |
| 45 | + |
| 46 | +3. **Error Messages** |
| 47 | + - Generic "authentication failed" doesn't guide to solution |
| 48 | + - No suggestion to run setup wizard |
| 49 | + - Doesn't indicate which auth method was attempted |
| 50 | + |
| 51 | +4. **Security Concerns** |
| 52 | + - Passwords stored in plain text in config |
| 53 | + - No support for credential helpers or keychains |
| 54 | + - Environment variables expose secrets in process list |
| 55 | + |
| 56 | +5. **Testing & Validation** |
| 57 | + - No way to test credentials without running actual command |
| 58 | + - No dry-run mode to show what would be executed |
| 59 | + - Can't verify connection before saving profile |
| 60 | + |
| 61 | +## Proposed Improvements |
| 62 | + |
| 63 | +### 1. Interactive Setup Wizard |
| 64 | + |
| 65 | +```bash |
| 66 | +# First-time setup |
| 67 | +$ redisctl setup |
| 68 | +Welcome to redisctl! Let's configure your Redis connection. |
| 69 | +
|
| 70 | +? What type of Redis deployment? (Use arrow keys) |
| 71 | +❯ Redis Cloud |
| 72 | + Redis Enterprise |
| 73 | + |
| 74 | +? Enter your Redis Cloud API credentials: |
| 75 | + API Key: ******** |
| 76 | + API Secret: ******** |
| 77 | + |
| 78 | +? Test connection? (Y/n) Y |
| 79 | +✓ Successfully connected to Redis Cloud! |
| 80 | +
|
| 81 | +? Save as profile? (Y/n) Y |
| 82 | +? Profile name: (production) |
| 83 | +? Set as default profile? (Y/n) Y |
| 84 | +
|
| 85 | +Configuration saved! You can now use: redisctl database list |
| 86 | +``` |
| 87 | +
|
| 88 | +### 2. Authentication Testing Command |
| 89 | +
|
| 90 | +```bash |
| 91 | +# Test current configuration |
| 92 | +$ redisctl auth test |
| 93 | +Testing authentication... |
| 94 | +✓ Profile: production (default) |
| 95 | +✓ Type: Redis Cloud |
| 96 | +✓ API URL: https://api.redislabs.com/v1 |
| 97 | +✓ Credentials: Valid |
| 98 | +✓ Permissions: Read/Write |
| 99 | +✓ Account: acme-corp (ID: 12345) |
| 100 | +
|
| 101 | +# Test specific profile |
| 102 | +$ redisctl auth test --profile staging |
| 103 | +Testing authentication... |
| 104 | +✗ Profile: staging |
| 105 | +✗ Type: Redis Enterprise |
| 106 | +✗ URL: https://cluster.example.com:9443 |
| 107 | +✗ Error: Connection refused |
| 108 | + |
| 109 | + Suggestions: |
| 110 | + - Check if the cluster URL is correct |
| 111 | + - Verify the cluster is accessible from your network |
| 112 | + - Try with --insecure flag if using self-signed certificates |
| 113 | +``` |
| 114 | +
|
| 115 | +### 3. Configuration Management Commands |
| 116 | +
|
| 117 | +```bash |
| 118 | +# Show configuration details |
| 119 | +$ redisctl config show |
| 120 | +Active Configuration: |
| 121 | + Source: Environment Variables |
| 122 | + Type: Redis Enterprise |
| 123 | + URL: https://localhost:9443 |
| 124 | + User: admin@redis.local |
| 125 | + |
| 126 | +Available Profiles: |
| 127 | + - production (Cloud) [default] |
| 128 | + - staging (Enterprise) |
| 129 | + - local (Enterprise) |
| 130 | +
|
| 131 | +# Show config file location |
| 132 | +$ redisctl config path |
| 133 | +/Users/alice/Library/Application Support/com.redis.redisctl/config.toml |
| 134 | +
|
| 135 | +# Edit config file |
| 136 | +$ redisctl config edit |
| 137 | +# Opens in $EDITOR |
| 138 | +
|
| 139 | +# Export configuration (without secrets) |
| 140 | +$ redisctl config export |
| 141 | +profiles: |
| 142 | + production: |
| 143 | + type: cloud |
| 144 | + api_url: https://api.redislabs.com/v1 |
| 145 | + # Credentials hidden - set via environment or prompt |
| 146 | +``` |
| 147 | +
|
| 148 | +### 4. Improved Error Messages |
| 149 | +
|
| 150 | +```bash |
| 151 | +$ redisctl database list |
| 152 | +Error: Authentication failed for Redis Cloud |
| 153 | +
|
| 154 | +The API returned: 401 Unauthorized |
| 155 | +Current configuration source: Environment variables |
| 156 | +
|
| 157 | +Possible solutions: |
| 158 | +1. Check your API credentials: |
| 159 | + - REDIS_CLOUD_API_KEY is set but may be incorrect |
| 160 | + - REDIS_CLOUD_API_SECRET is set but may be incorrect |
| 161 | +
|
| 162 | +2. Run setup wizard: |
| 163 | + redisctl setup |
| 164 | +
|
| 165 | +3. Test your credentials: |
| 166 | + redisctl auth test |
| 167 | +
|
| 168 | +4. Use a different profile: |
| 169 | + redisctl database list --profile <name> |
| 170 | +
|
| 171 | +For more help: redisctl help auth |
| 172 | +``` |
| 173 | +
|
| 174 | +### 5. Secure Credential Storage |
| 175 | +
|
| 176 | +```bash |
| 177 | +# Use system keychain (macOS) |
| 178 | +$ redisctl config set production --use-keychain |
| 179 | +Password will be stored in macOS Keychain |
| 180 | +
|
| 181 | +# Use credential helper |
| 182 | +$ redisctl config set production --credential-helper "pass show redis/production" |
| 183 | +
|
| 184 | +# Use 1Password CLI |
| 185 | +$ redisctl config set production --credential-helper "op read op://Redis/production/password" |
| 186 | +
|
| 187 | +# Prompt for password |
| 188 | +$ redisctl config set production --prompt-password |
| 189 | +Password will be requested when needed |
| 190 | +``` |
| 191 | +
|
| 192 | +### 6. Environment Detection |
| 193 | +
|
| 194 | +```bash |
| 195 | +# Auto-detect Redis Enterprise in Docker |
| 196 | +$ redisctl detect |
| 197 | +Detected Redis Enterprise at https://localhost:9443 |
| 198 | +Would you like to configure a profile for this cluster? (Y/n) |
| 199 | +
|
| 200 | +# Auto-detect from kubectl context |
| 201 | +$ redisctl detect --k8s |
| 202 | +Detected Redis Enterprise Operator in namespace 'redis' |
| 203 | +Found cluster: prod-cluster-redis-enterprise |
| 204 | +Would you like to configure a profile? (Y/n) |
| 205 | +``` |
| 206 | +
|
| 207 | +## Implementation Plan |
| 208 | +
|
| 209 | +### Phase 1: Core Improvements (Priority: High) |
| 210 | +1. Add `auth test` command for credential validation |
| 211 | +2. Implement `config show` and `config path` commands |
| 212 | +3. Improve error messages with actionable suggestions |
| 213 | +4. Add `--dry-run` flag to show what would be executed |
| 214 | +
|
| 215 | +### Phase 2: Setup Wizard (Priority: High) |
| 216 | +1. Create interactive setup wizard using `dialoguer` or `inquire` |
| 217 | +2. Add connection testing during setup |
| 218 | +3. Support profile creation and editing |
| 219 | +4. Add migration from existing .env files |
| 220 | +
|
| 221 | +### Phase 3: Security Enhancements (Priority: Medium) |
| 222 | +1. Integrate with system keychains (keyring-rs) |
| 223 | +2. Support credential helpers |
| 224 | +3. Add password prompting option |
| 225 | +4. Implement secure token refresh for OAuth |
| 226 | +
|
| 227 | +### Phase 4: Advanced Features (Priority: Low) |
| 228 | +1. Auto-detection of local Redis instances |
| 229 | +2. Kubernetes integration for operator detection |
| 230 | +3. Import from existing redis-cli configurations |
| 231 | +4. Export to other formats (env, docker-compose) |
| 232 | +
|
| 233 | +## Benefits |
| 234 | +
|
| 235 | +1. **Reduced Setup Time** |
| 236 | + - From 10+ minutes reading docs to 1 minute wizard |
| 237 | + - No need to find correct environment variable names |
| 238 | +
|
| 239 | +2. **Fewer Support Issues** |
| 240 | + - Clear error messages reduce confusion |
| 241 | + - Built-in testing prevents misconfiguration |
| 242 | + - Guided setup reduces errors |
| 243 | +
|
| 244 | +3. **Better Security** |
| 245 | + - Passwords not stored in plain text |
| 246 | + - Integration with existing credential stores |
| 247 | + - Reduced exposure in environment variables |
| 248 | +
|
| 249 | +4. **Improved Developer Experience** |
| 250 | + - Similar to `aws configure` or `gcloud init` |
| 251 | + - Familiar patterns from other CLI tools |
| 252 | + - Progressive disclosure of complexity |
| 253 | +
|
| 254 | +## Success Metrics |
| 255 | +
|
| 256 | +- Setup time for new users < 2 minutes |
| 257 | +- Authentication error resolution < 1 minute |
| 258 | +- 50% reduction in auth-related support issues |
| 259 | +- 90% of users successfully connect on first attempt |
| 260 | +
|
| 261 | +## Comparison with Curl |
| 262 | +
|
| 263 | +### Current curl approach: |
| 264 | +```bash |
| 265 | +# Users need to: |
| 266 | +# 1. Find API endpoint documentation |
| 267 | +# 2. Figure out authentication headers |
| 268 | +# 3. Construct complex curl commands |
| 269 | +# 4. Parse JSON responses manually |
| 270 | +
|
| 271 | +curl -X GET https://api.redislabs.com/v1/subscriptions \ |
| 272 | + -H "x-api-key: $REDIS_CLOUD_API_KEY" \ |
| 273 | + -H "x-api-secret-key: $REDIS_CLOUD_API_SECRET" \ |
| 274 | + -H "Content-Type: application/json" | jq '.' |
| 275 | +``` |
| 276 | +
|
| 277 | +### With improved redisctl: |
| 278 | +```bash |
| 279 | +# One-time setup |
| 280 | +redisctl setup |
| 281 | +
|
| 282 | +# Then just: |
| 283 | +redisctl cloud subscription list |
| 284 | +``` |
| 285 | +
|
| 286 | +The difference is dramatic - from error-prone manual API calls to simple, validated commands. |
0 commit comments