|
1 | 1 | # Authentication & SSO Management |
2 | 2 |
|
| 3 | +## Authentication Methods |
| 4 | + |
| 5 | +CodeMie CLI supports multiple authentication methods: |
| 6 | + |
| 7 | +- **CodeMie SSO** - Browser-based Single Sign-On (recommended for enterprise) |
| 8 | +- **JWT Bearer Authorization** - Token-based authentication for CI/CD and external auth systems |
| 9 | +- **API Key** - Direct API key authentication for other providers (OpenAI, Anthropic, etc.) |
| 10 | + |
3 | 11 | ## AI/Run CodeMie SSO Setup |
4 | 12 |
|
5 | 13 | For enterprise environments with AI/Run CodeMie SSO (Single Sign-On): |
@@ -103,3 +111,142 @@ AI/Run CodeMie SSO provides enterprise-grade features: |
103 | 111 | - **Automatic Plugin Installation**: Claude Code plugin auto-installs for session tracking |
104 | 112 | - **Audit Logging**: Enterprise audit trails for security compliance |
105 | 113 | - **Role-Based Access**: Model access based on organizational permissions |
| 114 | + |
| 115 | +## JWT Bearer Authorization |
| 116 | + |
| 117 | +For environments with external token management systems, CI/CD pipelines, or testing scenarios, CodeMie CLI supports JWT Bearer Authorization. This method provides tokens at runtime rather than during setup. |
| 118 | + |
| 119 | +### Initial Setup |
| 120 | + |
| 121 | +JWT setup only requires the API URL - tokens are provided later: |
| 122 | + |
| 123 | +```bash |
| 124 | +codemie setup |
| 125 | +# Select: Bearer Authorization |
| 126 | +``` |
| 127 | + |
| 128 | +**The wizard will:** |
| 129 | +1. Prompt for the CodeMie base URL (e.g., `https://codemie.lab.epam.com`) |
| 130 | +2. Optionally ask for a custom environment variable name (default: `CODEMIE_JWT_TOKEN`) |
| 131 | +3. Save the configuration without requiring a token |
| 132 | +4. Display instructions for providing tokens at runtime |
| 133 | + |
| 134 | +### Providing JWT Tokens |
| 135 | + |
| 136 | +After setup, provide tokens via environment variable or CLI option: |
| 137 | + |
| 138 | +**Environment Variable (Recommended):** |
| 139 | +```bash |
| 140 | +# Set token in your environment |
| 141 | +export CODEMIE_JWT_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." |
| 142 | + |
| 143 | +# Run commands normally |
| 144 | +codemie-claude "analyze this code" |
| 145 | +``` |
| 146 | + |
| 147 | +**CLI Option:** |
| 148 | +```bash |
| 149 | +# Provide token per command |
| 150 | +codemie-claude --jwt-token "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." "analyze this code" |
| 151 | +``` |
| 152 | + |
| 153 | +**Custom Environment Variable:** |
| 154 | +```bash |
| 155 | +# If you configured a custom env var during setup |
| 156 | +export MY_CUSTOM_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." |
| 157 | +codemie-claude "analyze this code" |
| 158 | +``` |
| 159 | + |
| 160 | +### JWT Token Management |
| 161 | + |
| 162 | +JWT tokens are validated automatically: |
| 163 | + |
| 164 | +```bash |
| 165 | +# Check JWT authentication status |
| 166 | +codemie doctor |
| 167 | + |
| 168 | +# View token status and expiration |
| 169 | +codemie profile status |
| 170 | +``` |
| 171 | + |
| 172 | +**Token Validation:** |
| 173 | +- Format validation (header.payload.signature) |
| 174 | +- Expiration checking (warns if expiring within 7 days) |
| 175 | +- Automatic error messages for expired tokens |
| 176 | + |
| 177 | +### Use Cases |
| 178 | + |
| 179 | +JWT Bearer Authorization is ideal for: |
| 180 | + |
| 181 | +**CI/CD Pipelines:** |
| 182 | +```bash |
| 183 | +# GitLab CI example |
| 184 | +script: |
| 185 | + - export CODEMIE_JWT_TOKEN="${CI_JOB_JWT}" |
| 186 | + - codemie-claude --task "review changes in this commit" |
| 187 | +``` |
| 188 | + |
| 189 | +**External Auth Systems:** |
| 190 | +```bash |
| 191 | +# Obtain token from your auth provider |
| 192 | +TOKEN=$(curl -s https://auth.example.com/token | jq -r .access_token) |
| 193 | + |
| 194 | +# Use with CodeMie |
| 195 | +codemie-claude --jwt-token "$TOKEN" "your prompt" |
| 196 | +``` |
| 197 | + |
| 198 | +**Testing & Development:** |
| 199 | +```bash |
| 200 | +# Use short-lived test tokens |
| 201 | +export CODEMIE_JWT_TOKEN="test-token-expires-in-1h" |
| 202 | +codemie-claude "run tests" |
| 203 | +``` |
| 204 | + |
| 205 | +### JWT vs SSO |
| 206 | + |
| 207 | +| Feature | JWT Bearer Auth | CodeMie SSO | |
| 208 | +|---------|----------------|-------------| |
| 209 | +| **Setup** | URL only | Browser-based flow | |
| 210 | +| **Token Source** | Runtime (CLI/env) | Stored in keychain | |
| 211 | +| **Best For** | CI/CD, external auth | Interactive development | |
| 212 | +| **Token Refresh** | Manual (obtain new token) | Automatic | |
| 213 | +| **Security** | Token management external | Managed by CLI | |
| 214 | + |
| 215 | +### Troubleshooting JWT |
| 216 | + |
| 217 | +**Token not found:** |
| 218 | +```bash |
| 219 | +# Check environment variable |
| 220 | +echo $CODEMIE_JWT_TOKEN |
| 221 | + |
| 222 | +# Verify variable name matches config |
| 223 | +codemie profile status |
| 224 | + |
| 225 | +# Provide via CLI instead |
| 226 | +codemie-claude --jwt-token "your-token" "your prompt" |
| 227 | +``` |
| 228 | + |
| 229 | +**Token expired:** |
| 230 | +```bash |
| 231 | +# Obtain new token from your auth provider |
| 232 | +export CODEMIE_JWT_TOKEN="new-token-here" |
| 233 | + |
| 234 | +# Verify expiration |
| 235 | +codemie doctor |
| 236 | +``` |
| 237 | + |
| 238 | +**Invalid token format:** |
| 239 | +```bash |
| 240 | +# JWT must have 3 parts (header.payload.signature) |
| 241 | +# Check token structure |
| 242 | +echo $CODEMIE_JWT_TOKEN | awk -F. '{print NF}' # Should output: 3 |
| 243 | +``` |
| 244 | + |
| 245 | +**Configuration issues:** |
| 246 | +```bash |
| 247 | +# Reset and reconfigure |
| 248 | +codemie setup # Choose Bearer Authorization again |
| 249 | + |
| 250 | +# Or manually edit config |
| 251 | +cat ~/.codemie/codemie-cli.config.json |
| 252 | +``` |
0 commit comments