Prompt
Do I need API gateway auth for SaaS microservices?
Latest observation
Not always — but some kind of auth at the gateway is usually a good idea for SaaS microservices.
Short answer
-
Yes, if the gateway is public-facing. It should typically handle:
- user authentication
- token validation
- rate limiting
- request routing
- basic authorization checks
-
No, if your services are strictly internal and never exposed externally. In that case, auth may live elsewhere, but you still need service-to-service security.
Common SaaS pattern
For a SaaS platform, the usual setup is:
-
API Gateway authenticates the caller
- OAuth2 / OIDC / JWT validation
- API keys for partner/system access if needed
-
Gateway passes trusted identity context downstream
- user ID
- tenant ID
- scopes/roles
-
Microservices enforce authorization
- confirm the user can access the specific resource
- enforce tenant isolation
- don’t rely only on the gateway for security
Why gateway auth helps
It centralizes:
- login/token verification
- rate limiting / abuse protection
- WAF-like protections
- audit logging
- request normalization
This reduces duplication across services.
What not to do
Don’t make the gateway your only security layer.
If a service can be reached internally or by another service, it should still verify:
- identity
- tenant context
- permissions
- request integrity where relevant
Recommended approach
For most SaaS microservice systems:
- Public traffic: authenticate at the API gateway
- Internal traffic: use mTLS, service identities, or internal JWTs
- Per-service authorization: still validate in each service
- Multi-tenancy: enforce tenant boundaries in the services and data layer
If you want, I can sketch a recommended auth architecture for SaaS microservices using JWT/OIDC + gateway + service-to-service auth.