Authentication Flow
AWSops handles authentication using Amazon Cognito + Lambda@Edge + CloudFront.
Cognito Configuration
| Item | Setting |
|---|---|
| User Pool | awsops-user-pool (self-signup disabled) |
| Sign-in | Email or username |
| Password Policy | 8+ characters, upper/lowercase + digits required |
| OAuth | Authorization Code Grant, OpenID/Email/Profile |
| Token Validity | 1 hour |
| Login UI | Custom login page (/awsops/login) — Cognito Hosted UI not used |
| Auth flow | USER_PASSWORD_AUTH (InitiateAuth) via /api/auth |
Authentication Flow Details
First Visit (No Cookie)
- Browser navigates to
/awsops - CloudFront triggers Lambda@Edge on viewer-request
- Lambda@Edge checks for
awsops_tokencookie → not found/expired - 302 redirect to the custom login page
/awsops/login(not Cognito Hosted UI) - User enters email/password →
POST /awsops/api/auth(action: login) - Server calls Cognito InitiateAuth (
USER_PASSWORD_AUTH) → obtains IdToken - Sets
awsops_tokenHttpOnly·Secure·SameSite=Lax cookie (1 hour) - Authenticated requests then flow through CloudFront → ALB → EC2
Return Visit (Valid Cookie)
- Browser sends request with
awsops_tokencookie - Lambda@Edge validates JWT → valid
- Request passes through CloudFront → ALB → EC2
Lambda@Edge
| Item | Setting |
|---|---|
| Region | us-east-1 (required for Lambda@Edge) |
| Runtime | Python 3.12 (deployed handler; CDK stub is Node.js 20) |
| Trigger | CloudFront viewer-request |
| Functions | JWT validation, OAuth2 callback handling, cookie management |
Sign Out
HttpOnly cookies cannot be deleted via JavaScript (document.cookie). AWSops deletes cookies server-side via POST /api/auth.
Related Pages
- Login - How to log in
- Deployment Guide - Cognito deployment steps
- Dashboard - System architecture overview