Authentication Guide
Alprina offers three authentication methods to suit different use cases. Choose the method that best fits your workflow.
Authentication Methods
1. GitHub OAuth (Web Dashboard)
Best for: Users who prefer browser-based access
How it works:
- Visit alprina.com
- Click “Sign in with GitHub”
- Authorize Alprina to access your GitHub account
- Redirected to dashboard
- API key automatically generated
Advantages:
- ✅ Quick and easy
- ✅ No password to remember
- ✅ Leverages GitHub security (2FA, etc.)
- ✅ Automatic API key generation
Use cases:
- First-time users
- Dashboard access
- Quick project setup
2. API Key Authentication (CLI & API)
Best for: Command-line users, CI/CD pipelines, programmatic access
How it works:
- Generate API key from dashboard
- Set environment variable or use CLI login
- Run commands authenticated
Setup:
# Method A: Environment variable (recommended)
export ALPRINA_API_KEY="sk_live_your_key_here"
alprina scan ./src
# Method B: CLI login
alprina auth login --api-key sk_live_your_key_here
alprina scan ./src
# Method C: Per-command
alprina scan ./src --api-key sk_live_your_key_hereAdvantages:
- ✅ Works in headless environments
- ✅ Perfect for automation
- ✅ Fine-grained access control (coming: scoped keys)
- ✅ Easy to rotate
Use cases:
- CI/CD pipelines
- Automated scripts
- Server deployments
- API integrations
3. Device Authorization Flow (CLI Interactive)
Best for: CLI users who prefer browser login
How it works:
- Run
alprina auth login(no flags) - CLI displays a code and URL
- Open URL in browser
- Enter code
- Authorize in browser
- CLI automatically authenticated
Example:
$ alprina auth login
Opening browser for authentication...
Visit: https://www.alprina.com/authorize
Enter code: ABCD-1234
Waiting for authorization...
✓ Authentication successful!
API key saved to ~/.alprina/config.jsonAdvantages:
- ✅ No need to copy/paste API keys
- ✅ Browser-based security
- ✅ Easy for first-time CLI users
- ✅ Automatic key storage
Use cases:
- Local development
- First-time CLI setup
- Users uncomfortable with API keys
Quick Start by Use Case
For Dashboard Users
1. Go to alprina.com
2. Click "Sign in with GitHub"
3. Authorize
4. Start using dashboardFor CLI Users (First Time)
# Interactive browser flow
alprina auth login
# Or with API key from dashboard
alprina auth login --api-key sk_live_...For CI/CD Pipelines
# GitHub Actions example
- name: Alprina Scan
run: alprina scan ./src
env:
ALPRINA_API_KEY: ${{ secrets.ALPRINA_API_KEY }}For API Integration
import alprina
client = alprina.Client(
api_key=os.getenv("ALPRINA_API_KEY")
)
result = client.scan("./src", scan_type="code")Authentication Flow Diagrams
GitHub OAuth Flow
User → GitHub → Supabase Auth → Alprina Backend → Dashboard
↓
JWT Token Created
↓
API Key GeneratedAPI Key Flow
Dashboard → Create API Key → Copy Key → Set in Environment
↓
Use in CLI/APIDevice Authorization Flow
CLI → Request Code → Display to User
↓
Browser → Enter Code → Authorize
↓
CLI ← Receive Token ← Backend validates
↓
Save to configManaging Authentication
Check Current Auth Status
# CLI
alprina auth status
# Output:
# ✓ Authenticated
# User: john@example.com
# Tier: Developer
# API Key: sk_live_...abc (last 3 chars)
# Expires: NeverLogout
# Remove stored credentials
alprina auth logout
# Confirm:
# ✓ Logged out successfully
# Local credentials removedSwitch Accounts
# Logout first
alprina auth logout
# Login with different account
alprina auth login --api-key sk_live_different_keySecurity Best Practices
For API Keys
-
Never commit to Git
# .gitignore .env .alprina/ alprina-config.json -
Use environment variables
# .env ALPRINA_API_KEY=sk_live_... # Load in scripts source .env alprina scan ./src -
Rotate regularly
# Every 90 days # 1. Create new key in dashboard # 2. Update systems # 3. Revoke old key -
Use separate keys per environment
Production: sk_live_prod_... Staging: sk_live_staging_... CI/CD: sk_live_ci_... Development: sk_live_dev_...
For GitHub OAuth
- Enable 2FA on GitHub
- Review authorized apps regularly
- Revoke access if account compromised
For All Methods
- Monitor login activity (coming soon)
- Set up alerts for unusual activity (coming soon)
- Use strong passwords for dashboard
- Keep CLI updated:
pip install --upgrade alprina-cli
Troubleshooting
Authentication Failed
Symptoms:
Error: 401 Unauthorized
Invalid API keySolutions:
- Check API key is correct
- Verify not revoked in dashboard
- Try generating new key
- Ensure no extra spaces/newlines
GitHub OAuth Not Working
Symptoms:
- Redirect fails
- Authorization doesn’t complete
Solutions:
- Check browser cookies enabled
- Disable ad blockers
- Try incognito/private mode
- Clear browser cache
- Try different browser
Device Flow Timeout
Symptoms:
Error: Authorization timeout
Device code expiredSolutions:
- Restart:
alprina auth login - Complete authorization within 15 minutes
- Check internet connection
- Try API key method instead
Permission Denied
Symptoms:
Error: 403 Forbidden
Insufficient permissionsSolutions:
- Check subscription tier
- Verify API key scopes (when available)
- Contact support
Migration Guide
From Trial to Paid
- Upgrade in dashboard: Settings → Billing → Upgrade
- Authentication remains the same
- API keys continue working
- No re-authentication needed
From Old API Keys
If you have old API keys:
- Generate new keys in dashboard
- Update systems with new keys
- Revoke old keys
- Old format:
api_...(deprecated) - New format:
sk_live_...(current)
API Reference
For complete API documentation:
FAQ
Q: Which authentication method should I use? A: Dashboard users: GitHub OAuth. CLI/API users: API keys. First-time CLI: Device flow.
Q: Can I use multiple authentication methods? A: Yes, use GitHub OAuth for dashboard and API keys for CLI/API.
Q: How long do sessions last? A: Dashboard sessions: 7 days. API keys: No expiration (manual rotation recommended).
Q: Can I share API keys with my team? A: No, each team member should have their own account and API keys. Use Team tier for collaboration.
Q: What happens if my API key is compromised? A: Immediately revoke in dashboard, generate new key, update systems.
Q: Do I need to re-authenticate after upgrading? A: No, authentication persists across tier changes.