Design a Central Authentication Service
Problem Statement
Design a Central Authentication System that can securely authenticate users across multiple applications or services within an organization or ecosystem.
This service should be scalable, reusable, and support both session-based and token-based (e.g., JWT/OAuth2) authentication models.
🎯 Functional Requirements:
⚙️ Non-Functional Requirements:
🧱 Core Components:
ComponentDescription
Auth API Service
Main entry point for login, registration, token issuance
User Store
Stores user credentials and metadata securely
Token Service
Handles access/refresh token generation and validation
Session Store
Stores server-side session data (if required)
OAuth2 Provider Module
Enables 3rd party auth (e.g., Google, GitHub)
Admin Dashboard
Optional interface to manage users, sessions, policies
Audit Log System
Records auth-related events for monitoring and compliance
🛢️ Database Schema (Simplified):
users
1nginx
2CopyEdit
3user_id | email | password_hash | is_verified | created_at | last_loginrefresh_tokens
1nginx
2CopyEdit
3token_id | user_id | token | expiry | revoked | created_ataudit_logs
1sql
2CopyEdit
3event_id | user_id | event_type | timestamp | ip_address🔁 Flow (Login via Email/Password):
🧰 Suggested Tech Stack:
LayerTools
API Layer
Node.js / FastAPI / Spring Boot
Token Signing
JWT + HMAC or RSA
DB
PostgreSQL / MongoDB
Cache
Redis (for session management)
Queue (optional)
Kafka (for audit logs, event-driven auth)
MFA
TOTP (Google Authenticator)
🧠 Advanced Features (Optional for HLD Rounds):
📈 Scalability & Reliability: