Introduction
The platform implements authentication using NextAuth.js v5 with OAuth 2.0 providers. The system supports multiple OAuth providers and implements custom session management with JWT tokens.Authentication Flow
The authentication flow follows the OAuth 2.0 authorization code flow:- User initiates sign-in via OAuth provider (Google or GitHub)
- User is redirected to provider’s authentication page
- After successful authentication, user is redirected back to the application
- NextAuth processes the callback and creates a session
- User data is stored in the database and JWT token is generated
- Session information is available throughout the application
Supported Providers
The platform currently supports two OAuth providers:Google OAuth
Full Google OAuth integration with Calendar API access
GitHub OAuth
GitHub authentication provider
Authentication Endpoints
All authentication endpoints are available under/api/auth/:
Returns available authentication providers
Displays the sign-in page
Handles user sign-out
OAuth callback endpoint for each provider
Returns current session information
Quick Start
Check Available Providers
Initiate Sign In
Get Current Session
Sign Out
Session Structure
The session object contains user information and authentication tokens:User information from OAuth provider
Session expiration timestamp (ISO 8601 format)
Configuration
The NextAuth configuration is defined insrc/auth.ts:15:
Environment Variables
Required environment variables for authentication:Google OAuth client ID
Google OAuth client secret
Email address for admin user with special privileges
Security Features
JWT Tokens
Secure JSON Web Tokens with 30-day expiration
OAuth 2.0
Industry-standard OAuth 2.0 protocol
Secure Sessions
Session tokens stored securely with regular updates
Database Integration
User data persisted in PostgreSQL database
Next Steps
Google OAuth Setup
Configure Google OAuth with Calendar API
Session Management
Learn about JWT tokens and session handling