Authentication flow
Token issuance
If successful, Cognito returns JWT tokens:
- Access Token: For API authorization (1 hour expiry)
- Refresh Token: For obtaining new access tokens (30 days expiry)
- ID Token: Contains user information and claims
Login
Endpoint
Response
Password change required
For new users or after admin password reset:JWT tokens
Access token
Used for API authorization:Refresh token
Used to obtain new access tokens:ID token
Contains user information and custom attributes:Password reset
Two-step process
Code expiration
Verification codes expire after 24 hours.Password requirements
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character
- Cannot contain username or email
Role-based access control
User roles
The platform supports two roles:| Role | Permissions |
|---|---|
| User | Create proposals, upload documents, generate content |
| Admin | All user permissions + prompt management, user management |
Admin detection
Admin status is determined by Cognito group membership:is_admin: true in their ID token.
Protected endpoints
Admin-only endpoints check for admin status:Token verification
Middleware verification
All API requests are verified by authentication middleware:Client-side verification
Clients should check token expiry before making requests:Session management
Frontend implementation
The frontend uses Zustand for auth state management:Auto-refresh
Implement automatic token refresh before expiry:Security best practices
Token storage
✅ Use httpOnly cookies for production (not accessible via JavaScript)✅ Avoid localStorage for sensitive tokens (vulnerable to XSS)
✅ Use sessionStorage if localStorage is required (cleared on tab close)
Request security
✅ Always use HTTPS for API requests✅ Include CSRF tokens for state-changing operations
✅ Validate tokens on server - never trust client-side validation
Logout
✅ Clear all tokens from storage✅ Invalidate session on server (optional, Cognito handles this)
✅ Redirect to login page
Error handling
Common authentication errors
| Status | Error | Solution |
|---|---|---|
| 401 | Token expired | Refresh token or re-login |
| 401 | Invalid token | Re-login |
| 401 | Incorrect username or password | Check credentials |
| 403 | Admin access required | User lacks admin privileges |
| 404 | User not found | Check email or contact admin |
| 429 | Too many requests | Rate limited, wait before retry |
Frontend error handling
Next steps
Login API
Complete login endpoint reference
Password reset API
Password reset flow documentation
User management
Admin user management API
Frontend development
Frontend authentication implementation