This guide helps you diagnose and resolve common issues with SSO authentication.
# Check if proxy is running
curl http://localhost:8080/health
# Expected response: {"status": "ok"}# Validate configuration
python -m src.anthropic_server --sso-config config/sso_auth.yaml --validate-only
# Check for syntax errors or missing fields# Start proxy with debug logging
python -m src.anthropic_server \
--sso-config config/sso_auth.yaml \
--log-level DEBUG
# Watch logs in real-time
tail -f /var/log/llm-proxy/proxy.logSymptoms:
- Requests are processed without authentication
- No login banner displayed
- Configuration appears to be ignored
Diagnosis:
# Check if SSO is enabled in config
grep -A 5 "sso:" config/sso_auth.yaml
# Check environment variables
echo $SSO_ENABLED
# Check CLI flags
ps aux | grep anthropic_serverSolutions:
- Verify configuration file is loaded:
# Explicitly specify config file
python -m src.anthropic_server --sso-config config/sso_auth.yaml- Check YAML syntax:
# CORRECT
sso:
enabled: true
# INCORRECT (wrong indentation)
sso:
enabled: true- Verify enabled flag:
sso:
enabled: true # Must be true, not "true" or 1Symptoms:
- "Provider 'google' not configured" error
- Authentication flow doesn't start
- Provider selection page shows no providers
Diagnosis:
# Check provider configuration
grep -A 10 "providers:" config/sso_auth.yaml
# Verify provider name
# Names are case-sensitive: "google" not "Google"Solutions:
- Check provider name matches exactly:
# CORRECT
providers:
google: # lowercase
type: "oauth2"
# INCORRECT
providers:
Google: # uppercase won't work
type: "oauth2"- Verify all required fields are present:
google:
type: "oauth2" # Required
client_id: "..." # Required
client_secret: "..." # Required
discovery_url: "..." # Required for OIDC
scopes: ["openid", "email"] # Required- Check indentation:
# CORRECT
sso:
providers:
google:
type: "oauth2"
# INCORRECT (wrong indentation)
sso:
providers:
google:
type: "oauth2"Symptoms:
- "Invalid client" error from IdP
- "Unauthorized" error during OAuth2 flow
- Authentication fails after IdP login
Diagnosis:
# Check client ID and secret
grep -A 5 "google:" config/sso_auth.yaml
# Verify credentials in IdP console
# Google: https://console.cloud.google.com/apis/credentials
# Microsoft: https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredAppsSolutions:
-
Verify credentials are correct:
- Copy client ID and secret directly from IdP console
- Check for extra spaces or line breaks
- Ensure credentials are for the correct environment (dev vs prod)
-
Check redirect URI matches:
# In IdP configuration
redirect_uris:
- "http://localhost:8080/auth/callback" # Must match exactly
# In proxy configuration (automatic)
# Proxy uses: http://{host}:{port}/auth/callback- Verify credentials haven't expired:
- Some IdPs expire credentials after inactivity
- Regenerate credentials if needed
Symptoms:
- "Redirect URI mismatch" error from IdP
- "Invalid redirect_uri" error
- Authentication flow fails after IdP login
Diagnosis:
# Check proxy host and port
grep -E "host|port" config/sso_auth.yaml
# Expected redirect URI format:
# http://{host}:{port}/auth/callbackSolutions:
- Ensure exact match in IdP configuration:
# If proxy runs on localhost:8080
Redirect URI: http://localhost:8080/auth/callback
# If proxy runs on custom port
Redirect URI: http://localhost:3000/auth/callback
# If proxy runs on domain
Redirect URI: https://proxy.company.com/auth/callback
- No trailing slashes:
# CORRECT
http://localhost:8080/auth/callback
# INCORRECT
http://localhost:8080/auth/callback/
- Use HTTPS in production:
# Development
http://localhost:8080/auth/callback
# Production
https://proxy.company.com/auth/callback
Symptoms:
- "Session expired" message in agent
- Sandbox response with re-authentication URL
- Agent was working, now requires authentication
Diagnosis:
# Check session lifetime configuration
grep "session_lifetime_hours" config/sso_auth.yaml
# Check token status in database
sqlite3 /path/to/sso_auth.db "SELECT user_email, auth_expires_at FROM agent_tokens WHERE is_active = 1;"Solutions:
-
Re-authenticate via web interface:
- Open the re-authentication URL provided in the response
- Log in with your identity provider
- Session is restored automatically
- Agent continues working with same token
-
Increase session lifetime (if appropriate):
authorization:
session_lifetime_hours: 48 # Increase from default 24- Verify system time is correct:
# Check system time
date
# Sync time if needed
sudo ntpdate -s time.nist.govSymptoms:
- Re-authenticated successfully
- Agent still receives sandbox response
- Token appears invalid
Diagnosis:
# Check token status in database
sqlite3 /path/to/sso_auth.db "SELECT user_email, is_authenticated, auth_expires_at FROM agent_tokens WHERE token_hash = ?;"
# Check proxy logs for authentication errors
grep "authentication failed" /var/log/llm-proxy/proxy.logSolutions:
-
Verify token is configured correctly in agent:
- Check for extra spaces or line breaks
- Ensure token is used as Bearer token
- Verify agent configuration file is saved
-
Check database was updated:
-- Manually update if needed
UPDATE agent_tokens
SET is_authenticated = 1,
auth_expires_at = datetime('now', '+24 hours')
WHERE token_hash = ?;- Restart agent:
- Some agents cache authentication state
- Restart agent to reload configuration
Symptoms:
- Session expires too quickly
- Need to re-authenticate multiple times per day
- Session lifetime seems shorter than configured
Diagnosis:
# Check configured session lifetime
grep "session_lifetime_hours" config/sso_auth.yaml
# Check actual expiry times in database
sqlite3 /path/to/sso_auth.db "SELECT user_email, created_at, auth_expires_at FROM agent_tokens WHERE is_active = 1;"Solutions:
- Increase session lifetime:
authorization:
session_lifetime_hours: 48 # Or higher- Check for clock skew:
# Ensure server and client clocks are synchronized
sudo ntpdate -s time.nist.gov- Review IdP session policies:
- Some IdPs have their own session limits
- Check IdP configuration for session timeout settings
Symptoms:
- "Authorization API timeout" error
- "Failed to connect to authorization API" error
- All users denied access
Diagnosis:
# Test API connectivity
curl -X POST http://company.com/api/authorize \
-H "Content-Type: application/json" \
-d '{"user_email": "test@example.com", "client_ip": "127.0.0.1"}'
# Check API logs
# Check network connectivity
ping company.comSolutions:
- Verify API URL is correct:
authorization:
api_url: "https://company.com/api/authorize" # Check protocol, domain, path- Increase timeout if API is slow:
authorization:
api_timeout_seconds: 10 # Increase from default 5-
Check network connectivity:
- Verify proxy can reach API server
- Check firewall rules
- Verify DNS resolution
-
Temporarily switch to single-user mode:
authorization:
mode: "single_user" # Fallback while debugging APISymptoms:
- All users denied access
- "Access denied" message for all authentication attempts
- API returns
{"authorized": false}
Diagnosis:
# Test API with known-good user
curl -X POST http://company.com/api/authorize \
-H "Content-Type: application/json" \
-d '{"user_email": "admin@example.com", "client_ip": "127.0.0.1"}'
# Check API logs for authorization decisionsSolutions:
-
Verify user is in allowed list:
- Check API's user database/configuration
- Ensure user email matches exactly (case-sensitive)
- Verify user has required roles/groups
-
Check API logic:
# Example: Verify allowed users list
ALLOWED_USERS = {
"alice@example.com", # Check email format
"bob@example.com"
}- Review API logs:
- Check why users are being denied
- Look for error messages or exceptions
Symptoms:
- "Authorization API error" in proxy logs
- HTTP 500 errors from API
- Intermittent authorization failures
Diagnosis:
# Check API logs for errors
tail -f /var/log/authorization-api/error.log
# Test API independently
curl -v -X POST http://company.com/api/authorize \
-H "Content-Type: application/json" \
-d '{"user_email": "test@example.com", "client_ip": "127.0.0.1"}'Solutions:
-
Fix API errors:
- Review API logs for stack traces
- Check database connectivity
- Verify external dependencies (LDAP, etc.)
-
Implement proper error handling:
@app.route("/api/authorize", methods=["POST"])
def authorize():
try:
# Authorization logic
return jsonify({"authorized": True})
except Exception as e:
app.logger.error(f"Authorization error: {e}")
return jsonify({
"authorized": False,
"reason": "Internal error"
}), 500- Add health check endpoint:
@app.route("/health", methods=["GET"])
def health():
# Check database, LDAP, etc.
return jsonify({"status": "ok"})Symptoms:
- No confirmation code in server console
- Web page says "Check server console" but no code visible
- Authentication completes but no code logged
Diagnosis:
# Check log level
grep "log-level" /proc/$(pgrep -f anthropic_server)/cmdline
# Check logs for confirmation code
grep "Confirmation Code" /var/log/llm-proxy/proxy.logSolutions:
- Set log level to WARNING or lower:
python -m src.anthropic_server \
--sso-config config/sso_auth.yaml \
--log-level WARNING # or INFO, DEBUG- Check authorization mode:
authorization:
mode: "single_user" # Must be single_user, not enterprise- Review logs for errors:
# Check for errors during authorization
grep -i "error" /var/log/llm-proxy/proxy.log | tail -20Symptoms:
- "Confirmation code expired" error
- Code was valid but now rejected
- Timeout during code entry
Diagnosis:
# Check code expiry configuration
grep "confirmation_code_expiry_minutes" config/sso_auth.yaml
# Check system time
dateSolutions:
-
Re-authenticate to get new code:
- Start SSO flow again
- New code will be generated
-
Increase expiry time:
authorization:
confirmation_code_expiry_minutes: 15 # Increase from default 10- Verify system time is correct:
# Sync time
sudo ntpdate -s time.nist.govSymptoms:
- "Maximum attempts exceeded" error
- Locked out after 3 failed attempts
- Cannot enter code anymore
Diagnosis:
# Check attempt limit configuration
grep "max_confirmation_attempts" config/sso_auth.yaml
# Check rate limit records
sqlite3 /path/to/sso_auth.db "SELECT * FROM rate_limits;"Solutions:
-
Re-authenticate via SSO:
- Start SSO flow again to get new code
- Attempts counter resets
-
Verify code is correct:
- Check for typos
- Ensure no spaces or extra characters
- Code is case-sensitive (if applicable)
-
Increase attempt limit (if appropriate):
authorization:
max_confirmation_attempts: 5 # Increase from default 3Symptoms:
- "Please wait before trying again" message
- Exponential backoff delay
- Cannot start new SSO flow
Diagnosis:
# Check rate limit records
sqlite3 /path/to/sso_auth.db "SELECT identifier, failed_attempts, blocked_until FROM rate_limits;"
# Check current time vs blocked_until
dateSolutions:
-
Wait for backoff period:
- Backoff increases exponentially: 2s, 4s, 8s, 16s, etc.
- Maximum wait: 5 minutes
-
Clear rate limit (if appropriate):
-- Clear rate limit for specific IP
DELETE FROM rate_limits WHERE identifier = '192.168.1.100';
-- Clear all rate limits (use with caution)
DELETE FROM rate_limits;- Adjust rate limit settings (future feature):
authorization:
rate_limit:
max_attempts: 10
backoff_multiplier: 2
max_backoff_seconds: 300Symptoms:
- Agent receives sandbox response
- Token appears to be ignored
- Authentication required despite token configuration
Diagnosis:
# Check agent configuration
cat ~/.continue/config.json # Continue
cat ~/.cursor/config.json # Cursor
cat ~/.aider.conf.yml # Aider
# Test token with curl
curl http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "test"}]}'Solutions:
-
Verify token is configured correctly:
- Check for extra spaces or line breaks
- Ensure token is complete (no truncation)
- Verify configuration file is saved
-
Check token format:
// CORRECT
{
"apiKey": "your-complete-token-here"
}
// INCORRECT (truncated)
{
"apiKey": "your-complete-token-he..."
}- Restart agent:
- Some agents cache configuration
- Restart to reload settings
Symptoms:
- Connection errors
- "404 Not Found" errors
- Agent cannot reach proxy
Diagnosis:
# Check agent base URL configuration
grep -i "base" ~/.continue/config.json
# Test base URL
curl http://localhost:8080/v1/modelsSolutions:
- Verify base URL format:
// CORRECT
{
"apiBase": "http://localhost:8080/v1"
}
// INCORRECT (missing /v1)
{
"apiBase": "http://localhost:8080"
}
// INCORRECT (extra slash)
{
"apiBase": "http://localhost:8080/v1/"
}- Check proxy is running on expected port:
# Check proxy port
netstat -tlnp | grep 8080
# Or use lsof
lsof -i :8080- Verify hostname/IP:
# For local proxy
apiBase: "http://localhost:8080/v1"
# For remote proxy
apiBase: "https://proxy.company.com/v1"Symptoms:
- "Database is locked" error
- Cannot write to database
- Concurrent access errors
Diagnosis:
# Check for processes using database
lsof /path/to/sso_auth.db
# Check database integrity
sqlite3 /path/to/sso_auth.db "PRAGMA integrity_check;"Solutions:
- Close other connections:
# Kill processes using database
lsof /path/to/sso_auth.db | awk 'NR>1 {print $2}' | xargs kill- Enable WAL mode (Write-Ahead Logging):
PRAGMA journal_mode=WAL;- Increase timeout:
# In database connection code
conn = sqlite3.connect('sso_auth.db', timeout=30.0)Symptoms:
- "Database disk image is malformed" error
- Cannot read from database
- Proxy fails to start
Diagnosis:
# Check database integrity
sqlite3 /path/to/sso_auth.db "PRAGMA integrity_check;"
# Check file permissions
ls -l /path/to/sso_auth.dbSolutions:
- Restore from backup:
# Restore database from backup
cp /path/to/backup/sso_auth.db /path/to/sso_auth.db- Attempt recovery:
# Dump and recreate database
sqlite3 /path/to/sso_auth.db ".dump" > dump.sql
mv /path/to/sso_auth.db /path/to/sso_auth.db.corrupt
sqlite3 /path/to/sso_auth.db < dump.sql- Recreate database (last resort):
# Backup corrupt database
mv /path/to/sso_auth.db /path/to/sso_auth.db.corrupt
# Start proxy (will create new database)
python -m src.anthropic_server --sso-config config/sso_auth.yaml
# Users will need to re-authenticateSymptoms:
- "Failed to connect to identity provider" error
- Timeout during OAuth2 flow
- DNS resolution errors
Diagnosis:
# Test IdP connectivity
curl -I https://accounts.google.com
# Check DNS resolution
nslookup accounts.google.com
# Check network connectivity
ping accounts.google.comSolutions:
-
Check network connectivity:
- Verify internet connection
- Check firewall rules
- Verify proxy settings (if behind corporate proxy)
-
Configure HTTP proxy (if needed):
export HTTP_PROXY=http://corporate-proxy:8080
export HTTPS_PROXY=http://corporate-proxy:8080- Check DNS settings:
# Verify DNS servers
cat /etc/resolv.conf
# Test with different DNS
nslookup accounts.google.com 8.8.8.8Symptoms:
- "Connection refused" error
- Cannot reach proxy from agent
- Timeout errors
Diagnosis:
# Check if proxy is running
ps aux | grep anthropic_server
# Check if port is listening
netstat -tlnp | grep 8080
# Test connectivity
curl http://localhost:8080/healthSolutions:
- Start proxy if not running:
python -m src.anthropic_server --sso-config config/sso_auth.yaml- Check firewall rules:
# Check iptables
sudo iptables -L -n
# Check firewalld
sudo firewall-cmd --list-all- Verify bind address:
# Listen on all interfaces
server:
host: "0.0.0.0"
port: 8080
# Listen on localhost only
server:
host: "127.0.0.1"
port: 8080When reporting issues, include:
- Proxy version:
python -m src.anthropic_server --version- Configuration (redact secrets):
cat config/sso_auth.yaml | sed 's/client_secret:.*/client_secret: REDACTED/'- Logs (last 50 lines):
tail -50 /var/log/llm-proxy/proxy.log-
Error messages:
- Full error text
- Stack traces (if available)
- Timestamps
-
Steps to reproduce:
- What you did
- What you expected
- What actually happened
python -m src.anthropic_server \
--sso-config config/sso_auth.yaml \
--log-level DEBUG \
--log-file /tmp/debug.log# Test SSO flow with curl
curl -v http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "test"}]}'
# Test authorization API independently
curl -v -X POST http://company.com/api/authorize \
-H "Content-Type: application/json" \
-d '{"user_email": "test@example.com", "client_ip": "127.0.0.1"}'- Configuration Options - Complete configuration reference
- Security Considerations - Security best practices
- Agent Configuration - Configure AI agents