Authentication Migration Guide
Overview
This guide provides detailed step-by-step instructions for migrating from the deprecated OIDC authentication system to the current authentication system.
Migration Benefits
- Enhanced Security: Session-based authentication with HttpOnly cookies prevents token exposure in browser
- Enterprise IdP Support: Support for OIDC with client secrets and SAML protocol
- Simplified Application: No token management in browser JavaScript
- Cross-Domain Support: Seamless authentication across multiple domains
- Automatic Token Refresh: Server-side token management and automatic refresh
Pre-Migration Checklist
Before starting the migration, ensure you have:
- [ ] Backup of current
lib/constants.tsandlib/config.json - [ ] OIDC client secret (if using confidential client flow)
- [ ] Understanding of your current OIDC configuration
- [ ] Planned maintenance window for deployment
- [ ] Reviewed the Authentication Configuration Guide
Pre-Migration Assessment
Current Configuration Review
Before starting the migration, document your current configuration:
Current OIDC Settings:
bash# Review current constants grep -E "OIDC_|IDP_" lib/constants.ts # Review current config cat lib/config.json | jq '.OIDC_URL, .OIDC_CLIENT_NAME'OIDC Provider Configuration:
- Current redirect URI
- Client type (public vs confidential)
- Available client secret (if confidential client)
- Supported authentication flows
Current Deployment:
- Environment (dev/staging/prod)
- Custom domains in use
Compatibility Check
Verify your OIDC provider supports the authentication requirements:
- ✅ Authorization Code flow
- ✅ Client secret support (for confidential clients)
- ✅ Token refresh capability
- ✅ Configurable redirect URIs
Migration Planning
Maintenance Window
Plan for a maintenance window during migration:
- Estimated Downtime: 15-30 minutes
- User Impact: All users will need to re-authenticate
- Rollback Time: 10-15 minutes if needed
Backup Strategy
Create backups before migration:
# Backup configuration files
cp lib/constants.ts lib/constants.ts.backup
cp lib/config.json lib/config.json.backupStep-by-Step Migration
Step 1: Update Configuration Files (example)
1.1 Update lib/constants.ts (if this was used for previous configuration)
// REMOVE these deprecated constants:
export const OIDC_URL = 'https://auth.example.com';
export const OIDC_CLIENT_NAME = 'mlspace-client';
export const OIDC_REDIRECT_URL = undefined;
export const OIDC_VERIFY_SSL = true;
export const OIDC_VERIFY_SIGNATURE = true;
// ADD these new AUTH constants:
export const AUTH_OIDC_URL = 'https://auth.example.com';
export const AUTH_OIDC_CLIENT_ID = 'mlspace-client';
// ADD any additioanl AUTH_OIDC* configuration parameters.1.2 Update lib/config.json (if this was used for previous configuration)
{
// REMOVE deprecated OIDC config:
// "OIDC_URL": "https://auth.dev.example.com",
// "OIDC_CLIENT_NAME": "mlspace-dev-client",
// ADD new AUTH config:
"AUTH_IDP_TYPE": "oidc",
"AUTH_OIDC_URL": "https://auth.dev.example.com",
"AUTH_OIDC_CLIENT_ID": "mlspace-dev-client",
"AUTH_SESSION_TTL_HOURS": 24
}Step 2: Update OIDC Provider Configuration
Update your OIDC provider's redirect URI configuration:
2.1 Current Redirect URI
https://your-api-gateway.execute-api.region.amazonaws.com/Prod/2.2 New Redirect URI
https://your-api-gateway.execute-api.region.amazonaws.com/Prod/auth/callback2.3 Provider-Specific Instructions
AWS Cognito:
- Go to AWS Cognito Console
- Select your User Pool
- Go to "App integration" → "App clients"
- Edit your MLSpace app client
- Update "Allowed callback URLs" to include
/auth/callback
Azure AD:
- Go to Azure Portal → Azure Active Directory
- Select "App registrations" → Your MLSpace app
- Go to "Authentication"
- Update redirect URI to include
/auth/callback
Keycloak:
- Go to Keycloak Admin Console
- Select your realm → Clients → Your MLSpace client
- Update "Valid Redirect URIs" to include
/auth/callback
Step 3: Build and Deploy
3.1 Build Frontend
Follow the instructions for building the frontend.
3.2 Deploy CDK Changes
Follow the instructions for deploying the CDK application.
Rollback Procedure
If issues occur during migration, follow this rollback procedure:
Step 1: Revert Configuration Files
# Restore backup files
cp lib/constants.ts.backup lib/constants.ts
cp lib/config.json.backup lib/config.jsonStep 2: Revert OIDC Provider Configuration
Restore the original redirect URI in your OIDC provider:
https://your-api-gateway.execute-api.region.amazonaws.com/Prod/Step 3: Build and Deploy
3.1 Build Frontend
Follow the instructions for building the frontend.
3.2 Deploy CDK Changes
Follow the instructions for deploying the CDK application.
Step 4: Verify Rollback
Test the deprecated authentication flow to ensure it's working correctly.