Cortex AI Authentication Guide¶
🔐 Authentication Methods¶
Cortex AI supports two authentication methods:
- Portal Tokens (Recommended) ⭐⭐⭐⭐⭐
- Zitadel SSO (Legacy)
✅ RECOMMENDED: Portal Token Authentication¶
Why Portal Tokens?¶
- ✅ Usage Tracking - Every API call is tracked per user
- ✅ Token Management - Create, revoke, and manage tokens
- ✅ Long-lived - Tokens last 1 year
- ✅ Offline-friendly - No browser popups
- ✅ Industry Standard - Like GitHub Copilot, Cursor, Augment
How to Get a Portal Token¶
Step 1: Sign Up / Login¶
- Go to https://app.cortex.emshvac.co
- Click "Login with Zitadel"
- Authenticate with your Zitadel account
- You'll be redirected to the Cortex Portal dashboard
Step 2: Generate a Token¶
- On the dashboard, find the "Personal Access Tokens" section
- Click "+ Create Token"
- A new token will be generated (format:
portal_xxx...) - Copy the token immediately - it won't be shown again!
Step 3: Configure VSCode¶
Option A: Via Settings UI
1. Open VSCode Settings (Cmd+, or Ctrl+,)
2. Search for "Cortex AI Token"
3. Paste your token in the cortexAI.token field
Option B: Via Command Palette
1. Open Command Palette (Cmd+Shift+P or Ctrl+Shift+P)
2. Type "Cortex: Configure Token"
3. Paste your token when prompted
Option C: Via settings.json
Step 4: Start Using Cortex!¶
That's it! The extension will now use your portal token for all API requests.
📊 Usage Tracking¶
What Gets Tracked?¶
When you use a portal token, the following is tracked in the database:
- Owner - Your email address
- Last Used - Timestamp of last API call
- Roles - Your permission level (admin, user, etc.)
- Permissions - Fine-grained access control
View Your Usage¶
- Go to https://app.cortex.emshvac.co
- View your tokens and their last usage
- See which tokens are active
Benefits¶
- Accountability - Know who's using the API
- Analytics - Track usage patterns
- Cost Attribution - Allocate costs per user
- Security - Revoke compromised tokens instantly
🔄 Token Management¶
Create Multiple Tokens¶
You can create multiple tokens for different purposes: - One for your work laptop - One for your personal laptop - One for CI/CD pipelines
Revoke Tokens¶
If a token is compromised: 1. Go to https://app.cortex.emshvac.co 2. Find the token in your dashboard 3. Click "Revoke" 4. The token is immediately invalidated
Token Expiration¶
- Tokens expire after 1 year
- You'll receive a notification before expiration
- Generate a new token when needed
🔐 LEGACY: Zitadel SSO (Device Code Flow)¶
When to Use¶
Only use this if: - You can't access the portal - You need temporary access - You're testing authentication
How It Works¶
- VSCode prompts for login
- Opens browser to Zitadel
- You enter a device code
- VSCode receives a JWT token
- Token is stored in VSCode secrets
Limitations¶
- ❌ No usage tracking - JWT tokens don't hit the database
- ❌ Short-lived - Tokens expire quickly
- ❌ Browser required - Can't work offline
- ❌ Complex UX - Device code flow is confusing
How to Use¶
- Make sure
cortexAI.tokenis empty - Make sure
cortexAI.enableAuthis true - Try to use Cortex
- VSCode will prompt for Zitadel login
- Follow the device code flow
🎯 Recommended Setup¶
For Individual Users¶
- ✅ Use Portal Tokens
- ✅ Generate one token per device
- ✅ Revoke tokens when changing devices
- ✅ Check usage periodically
For Teams¶
- ✅ Each user gets their own Zitadel account
- ✅ Each user generates their own portal token
- ✅ Admins can track usage per user
- ✅ Revoke access by revoking tokens
For CI/CD¶
- ✅ Create a service account in Zitadel
- ✅ Generate a portal token for the service account
- ✅ Store token in CI/CD secrets
- ✅ Track CI/CD usage separately
🔍 Troubleshooting¶
"Invalid or expired token"¶
- Check if token starts with
portal_ - Check if token is revoked in the portal
- Check if token has expired (1 year)
- Generate a new token
"No token configured"¶
- Open VSCode settings
- Search for "Cortex AI Token"
- Paste your portal token
- Reload VSCode
"Failed to authenticate"¶
- Check if
cortex.emshvac.cois accessible - Check your internet connection
- Try generating a new token
- Contact support
📝 Summary¶
| Feature | Portal Token | Zitadel SSO |
|---|---|---|
| Usage Tracking | ✅ Yes | ❌ No |
| Token Management | ✅ Yes | ❌ No |
| Long-lived | ✅ 1 year | ❌ Short |
| Offline | ✅ Yes | ❌ No |
| UX | ✅ Simple | ❌ Complex |
| Recommended | ✅ YES | ❌ Legacy |
Get started now: https://app.cortex.emshvac.co 🚀