Design: Authentication at Gateway Level in Microservices
Design focuses on authentication at the API gateway level in a microservices architecture. Authorization inside microservices and user management systems are out of scope.
Functional Requirements
FR1: Authenticate all incoming client requests before routing to microservices
FR2: Support token-based authentication (e.g., JWT)
FR3: Validate tokens efficiently to minimize latency
FR4: Allow unauthenticated access to public endpoints
FR5: Provide detailed error responses for authentication failures
FR6: Support role-based access control (RBAC) for downstream services
FR7: Log authentication attempts for auditing
FR8: Handle 10,000 concurrent requests with p99 latency under 150ms
FR9: Ensure 99.9% uptime for the authentication gateway
Non-Functional Requirements
NFR1: Authentication must happen only once at the gateway to reduce load on microservices
NFR2: Gateway should not become a single point of failure
NFR3: Token validation should be stateless to support horizontal scaling
NFR4: Latency added by authentication should be minimal
NFR5: System must be secure against common attacks (replay, token forgery)