Descope Authentication Setup
Complete guide to integrating and managing Descope authentication with Traefik.Overview
Descope is an enterprise authentication platform providing:- Single Sign-On (SSO)
- Magic links
- Passkeys
- Multi-factor authentication (MFA)
- OAuth/OpenID Connect
- User management
Architecture
Authentication Flow
Session Management
Setup Instructions
Step 1: Create Descope Account
- Visit https://descope.com
- Sign up for a free account
- Create a new project
- Copy your Project ID
Step 2: Configure Project ID
Update.env file:
Step 3: Set Session Secret
Generate a random secret:Step 4: Configure Descope Redirect
In Descope console:- Go to Project Settings
- Set redirect URI to:
https://auth.starfleet-command.dev/auth/callback - Save settings
Step 5: Deploy Service
Configuration Files
Docker Compose
Environment Variables
Using Descope Middleware
Adding Authentication to Services
To protect a service with Descope authentication:Service Without Authentication
To skip authentication for certain services:Authentication Methods
Magic Links
Users receive an email with a magic link to log in:Passkeys
Users can register and use passkeys (biometric/hardware):Multi-Factor Authentication
Add additional security layer:Session Management
Cookie Configuration
Sessions stored in HTTP-only secure cookies:Cross-Domain Sessions
The authentication cookie works across all subdomains:Session Validation
Each request is validated:Troubleshooting
Service Not Starting
Login Not Working
Symptoms: Stuck on login page after submitting credentials Causes:- PROJECT_ID incorrect
- Redirect URI not configured in Descope console
- SESSION_SECRET not set
- Verify PROJECT_ID in Descope console
- Check redirect URI: https://auth.starfleet-command.dev/auth/callback
- Generate new SESSION_SECRET:
openssl rand -base64 32 - Restart service:
docker compose restart descope-auth
Redirect Loop
Symptoms: Continuously redirected to login page Causes:- Middleware configuration error
- Session not being created properly
- Cookie domain incorrect
Can’t Access Protected Service
Symptoms: 403 Forbidden or 401 Unauthorized Causes:- Not authenticated
- Session expired
- Invalid middleware configuration
User Management
In Descope Console
- Go to Users section
- View all users
- Manage user permissions
- Reset user sessions
- Export user data
Programmatically
Descope provides SDKs for:- JavaScript/TypeScript
- Python
- Go
- Node.js
- Java
Custom Login Page
To customize the login page, modifypublic/index.html:
Best Practices
-
Always use HTTPS
- Sessions only work over HTTPS
- Set
secure: trueon cookies
-
Secure Session Secret
- Generate strong random secret
- Never commit to Git
- Rotate periodically
-
Monitor Sessions
- Review login logs
- Monitor for failed attempts
- Alert on suspicious activity
-
Test Authentication
- Test login flow
- Test logout flow
- Test session expiration
- Test on multiple devices/browsers
-
User Communication
- Clear login instructions
- Help for forgotten passwords
- Support contact information
API Endpoints
Verify Endpoint
Used by Traefik middleware:Callback Endpoint
Used after user authenticates:Logout Endpoint
Used to end session:Next: Troubleshooting Guide