OOOC Fête Finder implements a dual-tier authentication system: user authentication for content access and admin authentication for administrative functions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KingPsychopath/oooc-fete-finder/llms.txt
Use this file to discover all available pages before exploring further.
User authentication
User authentication is email-based and uses JWT tokens stored in HTTP-only cookies.Authentication flow
- User submits email via
POST /api/auth/verify - Server validates email format and rate limits
- User record created/updated in user collection store
- JWT token generated and signed with
AUTH_SECRET - Cookie set with HTTP-only flag
User session token
User sessions are signed JWT tokens with the following structure:HMAC-SHA256 symmetric signing
Tokens expire after 2,592,000 seconds (30 days)
HTTP-only cookie with SameSite=lax
features/auth/user-session-cookie.ts:32.
Security requirements
The secret is validated ingetUserAuthSecret() at features/auth/user-session-cookie.ts:17.
Cookie configuration
In production, cookies are restricted to HTTPS only (
secure: true). In development, HTTP is allowed for local testing.features/auth/user-session-cookie.ts:80.
Session verification
Session tokens are verified on each authenticated request:features/auth/user-session-cookie.ts:48.
Logout
Users can logout viaDELETE /api/auth/session, which clears the session cookie by setting maxAge: 0.
See logout implementation in app/api/auth/session/route.ts:33.
Admin authentication
Admin authentication is more sophisticated, supporting multiple credential types and session management.Credential types
Admins can authenticate using three methods:Direct key authentication using
ADMIN_KEY environment variableJWT bearer token for programmatic access
HTTP-only cookie for browser sessions
features/auth/admin-auth-token.ts:263.
Admin key authentication
The simplest form of admin authentication:Admin key comparison uses constant-time comparison via
timingSafeEqual to prevent timing attacks.features/auth/admin-auth-token.ts:55.
Admin JWT sessions
Admin sessions use JWT tokens with session tracking:HMAC-SHA256 symmetric signing
Admin tokens expire after 3,600 seconds
Unique session identifier for tracking and revocation
features/auth/admin-auth-token.ts:319.
Session tracking
All admin sessions are tracked in either:- Postgres:
app_admin_sessionstable (preferred) - KV Store: Fallback for environments without Postgres
features/auth/admin-auth-token.ts:220.
Token versioning
Admin tokens include a version number (tv) that enables mass revocation:
Incrementing the global token version instantly invalidates all existing admin sessions. This is useful for security incidents or credential rotation.
features/auth/admin-auth-token.ts:112.
Session revocation
Admin sessions can be revoked in two ways: Individual revocation:- Postgres:
revoked_untilcolumn inapp_admin_sessions - KV Store:
admin-auth:revoked:{jti}key
features/auth/admin-auth-token.ts:659.
Mass revocation:
features/auth/admin-auth-token.ts:692.
Session cleanup
Expired admin sessions are automatically cleaned up by a cron job:Sessions are kept for 7 days after expiry for audit purposes
Only sessions expired beyond the grace window are deleted
features/auth/admin-auth-token.ts:626.
Session status endpoint
Check authentication status viaGET /api/auth/session:
This endpoint returns both user and admin authentication status in a single request.
app/api/auth/session/route.ts:10.
Security best practices
Token security:- All tokens use HMAC-SHA256 signing
- Tokens include audience and issuer claims to prevent misuse
- Tokens are validated on every request
- Expired tokens are automatically rejected
- HTTP-only flag prevents JavaScript access
- SameSite=lax prevents CSRF attacks
- Secure flag enforces HTTPS in production
- Path restriction limits cookie scope
- Authentication endpoints are rate limited (see rate limiting)
- Failed attempts are tracked by IP and email combination
- Prevents brute force and enumeration attacks