Foundation OAuth Deployment Checklist
This checklist guides you through deploying Phase 3: Foundation OAuth integration on aethex.dev.
Pre-Deployment Setup
1. Environment Variables
Add these to your deployment platform (Vercel, Railway, etc.):
# Foundation Identity Provider
VITE_FOUNDATION_URL=https://aethex.foundation
# OAuth Credentials (from Foundation Phase 1 setup)
FOUNDATION_OAUTH_CLIENT_ID=aethex_corp
FOUNDATION_OAUTH_CLIENT_SECRET=bcoEtyQVGr6Z4557658eUXpDF5FDni2TGNahH3HT-FtylNrLCYwydwLO0sbKVHtfYUnZc4flAODa4BXkzxD_qgImportant:
✅ Keep
FOUNDATION_OAUTH_CLIENT_SECRETsecure (never commit to git)✅ Use deployment platform's secret management (Vercel > Settings > Environment Variables)
✅ Mark secret variables as "Encrypted"
2. Verify Foundation is Ready
Before deploying, confirm:
Quick Test:
3. Verify Redirect URI
Foundation must have this redirect URI registered:
Ask Foundation admin to verify these are registered.
Deployment Steps
Step 1: Set Environment Variables
Vercel:
Go to Project Settings > Environment Variables
Add three variables:
VITE_FOUNDATION_URL=https://aethex.foundationFOUNDATION_OAUTH_CLIENT_ID=aethex_corpFOUNDATION_OAUTH_CLIENT_SECRET= (paste secret, mark as encrypted)
Select environments: Production, Preview, Development
Save
Railway/Other:
Add to
.envfile in deploymentOr configure in platform's settings
Restart deployment for changes to take effect
Step 2: Deploy Code
Files included in deployment:
Deploy command:
Step 3: Verify Deployment
Check environment variables:
Visit login page:
Go to https://aethex.dev/login
Should see "Login with Foundation" button
No console errors
Test OAuth flow:
Click "Login with Foundation"
Should redirect to https://aethex.foundation/api/oauth/authorize
Page should show Foundation login (or auth screen)
Check callback endpoint:
Network tab should show POST to
/auth/callback/exchangeShould return 200 with access_token
Verify cookies:
After successful login, check Application > Cookies
Should have:
foundation_access_token,auth_user_idBoth should be HttpOnly, Secure, SameSite=Strict
Step 4: Monitor Logs
Watch for errors during first deployment:
Testing Plan
Test 1: Happy Path (Successful Login)
Steps:
Visit https://aethex.dev/login
Click "Login with Foundation"
Enter test credentials on Foundation
Should redirect back to aethex.dev/auth/callback
Should exchange code for token
Should appear logged in on dashboard
Expected Result: ✅ Logged in, cookies set, profile synced
Check:
Test 2: Error: Invalid Code
Steps:
Manually modify callback URL:
?code=invalid_code_123Press Enter
Expected Result: ⚠️ Error page with message, redirect to login after 2s
Test 3: Network Error
Steps:
Stop/pause Foundation service
Attempt login
Foundation redirects back with code
Callback tries to exchange code
Expected Result: ⚠️ Error about Foundation connection, graceful redirect to login
Test 4: Logout and Re-login
Steps:
Logout from dashboard (if logout button exists)
Check cookies are cleared
Login again with Foundation
Should work seamlessly
Expected Result: ✅ Logout clears cookies, re-login establishes new session
Test 5: Multiple Browsers
Test on:
Expected Result: ✅ Works consistently across all browsers
Production Rollout
Phase 1: Staging (First)
Deploy to staging environment first
Run full testing suite
Verify Foundation integration works
Get team sign-off
Monitor staging for 24 hours
Phase 2: Canary (Small Percentage)
If your deployment supports canary deployments:
Deploy to 5% of production traffic
Monitor auth success rate and errors
Check logs for issues
Gradually increase to 100%
Phase 3: Full Production
Deploy to 100% of production
Have support team on standby
Monitor metrics closely for 24 hours
Have rollback plan ready
Phase 4: Cleanup
After 1-2 weeks of successful deployment:
Remove old Discord OAuth code (optional)
Delete deprecated files:
code/api/discord/oauth/start.tscode/api/discord/oauth/callback.tscode/api/discord/link.tscode/api/discord/create-linking-session.tscode/api/discord/verify-code.ts
Update documentation
Remove old env variables
Rollback Plan
If critical issues occur:
Immediate Rollback (< 1 hour)
Revert deployment:
Remove environment variables:
Remove VITE_FOUNDATION_URL
Remove FOUNDATION_OAUTH_CLIENT_ID
Remove FOUNDATION_OAUTH_CLIENT_SECRET
Communicate with users:
"We've temporarily disabled Foundation integration"
"Use alternative login methods"
If Rollback Fails
Contact Foundation admin for assistance with:
OAuth endpoint status
User session validation
Database consistency
Monitoring & Alerts
Key Metrics to Monitor
Auth Success Rate
Target: >99%
Alert threshold: <95%
What to check: Logs for "Token exchange" errors
Token Exchange Time
Target: <500ms
Alert threshold: >2000ms
What to check: Network latency to Foundation
Foundation Connectivity
Monitor: Foundation endpoint availability
Alert on: Connection failures to /api/oauth/token
Fallback: Maintenance page if Foundation down
Error Rate by Type
invalid_code- Usually code expired, user retriesstate_mismatch- CSRF validation failed, investigatetoken_exchange_failed- Foundation issue, escalateuser_sync_failed- Database issue, check Supabase
Sample Metrics Query
Support & Troubleshooting
Common Issues During Deployment
"Client secret not found"
Missing env var
Add FOUNDATION_OAUTH_CLIENT_SECRET
"Redirect URI mismatch"
URI not registered on Foundation
Ask Foundation admin to register
"Token exchange failed 401"
Invalid credentials
Verify client_id and client_secret
"User sync failed"
Supabase error
Check user_profiles table schema
"Cookies not set"
SameSite policy blocking
Check cookie headers on response
Debug Commands
Getting Help
Check logs:
Deployment platform logs (Vercel Dashboard, Railway Dashboard)
Application logs (if available)
Browser console (F12)
Network tab (check requests/responses)
Verify configuration:
Environment variables set correctly
Foundation endpoints accessible
Redirect URI registered
Escalate if needed:
Contact Foundation admin for OAuth endpoint issues
Contact Supabase for database sync issues
Contact platform support for deployment issues
Post-Deployment
1. Verify Everything Works (Week 1)
2. Communicate with Users (Week 1)
3. Monitor Metrics (Week 2-3)
4. Final Cleanup (Week 3-4)
Success Criteria
✅ Deployment is successful when:
Login page shows "Login with Foundation" button
Users can login and are redirected to Foundation
After Foundation auth, users redirected back to dashboard
User profiles sync to local database
Cookies are set correctly (HttpOnly, Secure)
Auth success rate >99% for 24+ hours
No critical errors in logs
Support team has no blocking issues
Users report smooth login experience
All team members approve
Deployment Checklist
Ready to deploy? Follow this checklist step-by-step for a smooth Foundation OAuth integration!
Status: ✅ Deployment checklist complete and ready for use
Last updated
