Onboarding Status Web Authentication¶
Overview¶
The Onboarding Status Web dashboard uses Google OAuth 2.0 with server-side sessions for authentication. Only @vectorinstitute.ai email addresses can access the dashboard.
Architecture¶
- Library:
@vector-institute/aieng-auth-core - Session Management:
iron-sessionwith encrypted HTTP-only cookies - Security: PKCE flow, domain restriction, encrypted sessions
- Path: All routes under
/onboardingbase path
Authentication Flow¶
- User visits
/onboarding→ redirected to/onboarding/loginif not authenticated - Click "Sign in with Google" →
/onboarding/api/auth/login - Google OAuth flow with PKCE
- Callback to
/onboarding/api/auth/callback - Session created, user redirected to dashboard
Files¶
Configuration¶
lib/auth-config.ts- OAuth configlib/session.ts- Session management
API Routes¶
app/api/auth/login/route.ts- Initiate OAuthapp/api/auth/callback/route.ts- Handle callbackapp/api/auth/logout/route.ts- Destroy sessionapp/api/auth/session/route.ts- Get session info
Pages¶
app/page.tsx- Protected dashboardapp/login/page.tsx- Login pageapp/dashboard-content.tsx- Dashboard UI
Environment Variables¶
# OAuth
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-secret
SESSION_SECRET=generate-with-openssl-rand-base64-32
# URLs
NEXT_PUBLIC_APP_URL=http://localhost:3000
REDIRECT_URI=http://localhost:3000/onboarding/api/auth/callback
# Domain restriction
ALLOWED_DOMAINS=vectorinstitute.ai
Local Development¶
- Copy OAuth credentials from
aieng-template-auth/apps/demo-nextjs/.env - Update redirect URI in
.env:http://localhost:3000/onboarding/api/auth/callback - Run
npm run dev - Visit
http://localhost:3000/onboarding - Sign in with @vectorinstitute.ai account
Production Deployment¶
Required GitHub Secrets¶
GOOGLE_CLIENT_ID- Shared Vector OAuth client IDGOOGLE_CLIENT_SECRET- OAuth client secretSESSION_SECRET- Generated withopenssl rand -base64 32APP_URL- Production URL (e.g.,https://your-service.run.app)REDIRECT_URI- Production callback URL (e.g.,https://your-service.run.app/onboarding/api/auth/callback)
Setup Steps¶
- Get shared OAuth client ID from admin
- Ask admin to add production redirect URI to Google OAuth client
- Set GitHub secrets in repository settings
- Deploy via GitHub Actions workflow
Troubleshooting¶
"Invalid redirect_uri"
- Verify redirect URI registered in Google Cloud Console
- Check REDIRECT_URI matches registered value
"Unauthorized domain"
- User must have @vectorinstitute.ai email
- Check ALLOWED_DOMAINS environment variable
Session issues
- Verify SESSION_SECRET is at least 32 characters
- Clear browser cookies