Single Central Authentication System
Problem Statement
Design a Central Authentication System that can authenticate and authorize users across multiple internal or external applications/services.
This system should provide secure, scalable, and reusable identity and access management for web, mobile, and backend systems using protocols like OAuth2, JWT, SAML, etc.
🎯 Functional Requirements:
⚙️ Non-Functional Requirements:
🧱 Core Components:
ComponentDescription
Auth API Gateway
Entry point for login, signup, token operations
Identity Provider (IdP)
Issues tokens and handles federation
Token Service
Issues, refreshes, and validates JWTs
User Service
Manages user data and credentials
Session Store
Stores refresh tokens or active sessions (Redis, DB)
Audit Logging System
Tracks user activity and security events
Admin Dashboard (Optional)
For managing users, roles, and policies
🛢️ Database Schema (Simplified):
users
1nginx
2CopyEdit
3user_id | email | password_hash | is_verified | created_attokens
1nginx
2CopyEdit
3token_id | user_id | refresh_token | expires_at | revokedroles
1nginx
2CopyEdit
3role_id | role_name | permissionsuser_roles
1nginx
2CopyEdit
3user_id | role_id🔁 Flow: Login and Token Issuance
🔐 Token Format (JWT Claims):
1json
2CopyEdit
3{
4 "sub": "user123",
5 "email": "user@example.com",
6 "roles": ["admin", "editor"],
7 "iat": 1723453435,
8 "exp": 1723457035,
9 "iss": "central-auth-service"
10}📈 Scalability Considerations:
🧰 Suggested Tech Stack:
LayerTools/Technologies
API Gateway
NGINX / Kong / Envoy
Backend
Node.js / Go / Java / Python
Auth Protocols
OAuth2 / OpenID Connect / JWT
Database
PostgreSQL / MongoDB
Cache
Redis
Federation
SAML / OAuth with Google/Facebook