API KeysJWTOAuth 2.0OIDCmTLSHMACScopesRBAC

Authentication & Authorization

The most critical security function of a gateway. Verify identity once at the boundary — downstream services receive verified identity and trust the gateway.

45 min read9 sections
01

Authentication at the Gateway

The gateway is the authentication boundary. Every request entering your system passes through it, making it the natural place to verify identity. Once the gateway authenticates a request, it forwards verified identity information (user ID, roles, scopes) to downstream services via headers. Backend services trust the gateway — they don't re-verify tokens.

🛂

Airport Security Checkpoint

The gateway is like airport security. You verify identity and boarding pass once at the checkpoint. After that, you move freely between gates, shops, and lounges without showing ID again. Each gate (service) trusts that security already verified you. They just check your boarding pass (forwarded identity header) matches the flight (authorized resource).

Auth MethodBest ForStatefulness
API KeysServer-to-server, third-party integrationsStateful (key lookup)
JWT (Bearer Token)User sessions, mobile/SPA clientsStateless (signature verification)
OAuth 2.0 + OIDCDelegated access, SSO, third-party appsStateful (token introspection) or stateless (JWT)
mTLSService-to-service, high-security B2BStateless (certificate validation)
HMAC SigningWebhook verification, tamper-proof requestsStateless (signature computation)

The Downstream Trust Model

Once the gateway verifies a token, it strips the original Authorization header and injects internal headers: X-User-ID,X-User-Roles, X-Tenant-ID. Backend services trust these headers implicitly. This means backend services MUST NOT be directly accessible from outside — only through the gateway. If a service is exposed directly, anyone can forge these headers.

1 / 9