Problem
Every service implementing auth = duplication, inconsistency, token leakage. Gateway centralizes auth, services trust gateway headers.
Also known as: gateway-auth, jwt-validation, api-key, oauth2-gateway, mTLS-gateway
Centralize authentication at the API Gateway: JWT validation, API keys, OAuth2 introspection, mTLS — patterns for security and performance.
Every service implementing auth = duplication, inconsistency, token leakage. Gateway centralizes auth, services trust gateway headers.
solution: | Auth Methods at Gateway:
JWT Validation (most common)
kidX-User-ID, X-User-Roles, X-Scopes headers to upstreamAPI Key (simple, partner integrations)
OAuth2 Introspection (RFC 7662)
/introspect for opaque tokensmTLS (zero-trust, service-to-service)
X-Client-SPIFFE-ID for upstream authzOIDC / Social Login (end-user)
Patterns:
X-User-ID, X-Roles; services read headers (zero-trust: services also verify gateway mTLS)Performance:
Token Propagation:
Authorization header (services validate)Tools: Kong, Envoy, AWS API Gateway, Apigee, Kong, Traefik, NGINX Plus, ORY Oathkeeper. whenToUse: