API Gateway vs. Service: Where to Place Policies, Authorization, and Business Rules
An API gateway should handle routing and shared network-boundary policies, while each service should make the final decisions about business rules and access to its data. Even when the gateway authenticates callers or limits requests, services should check access to their own resources across bypass and internal-call paths.
An API gateway should handle routing and shared network-boundary policies, while each service should make the final decisions about business rules and access to its data. Even when the gateway authenticates callers or limits requests, services should check access to their own resources across bypass and internal-call paths.
A gateway is a reverse proxy in front of clients: it routes requests and can centralize shared functions such as TLS termination, IP rules, client-wide rate limits, request-size limits, and baseline logging. Decisions that depend on domain data—whether an order can be cancelled, who owns an account, or how much can be refunded—belong with the service that owns that data. Microsoft’s gateway guidance separates shared boundary functions from business logic and suggests a dedicated service when aggregation needs complex domain rules or long-running orchestration.
| Concern | Gateway responsibility | Service responsibility |
|---|---|---|
| Routing and transport security | Host/path routing, client TLS termination and re-encryption to backends, shared WAF policy | Authenticate backend peers; apply service-to-service policy and handle the business request |
| Authentication and authorization | Validate token shape/signature or start authentication; common client/network blocking | Check whether this caller may access this object or invoke this business function |
| Rate and capacity limits | Broad limits by IP, API product, or client key; reject oversized requests | Limits based on user, tenant, object, quota, or current business state |
| Input validation | Body size, media type, obvious protocol errors | Domain rules, cross-field constraints, and validity against current state |
| Transformation and composition | Lightweight header/path changes and shallow read aggregation | Complex transformations, multi-step orchestration, writes, and compensation |
| Observability | Entry request ID, policy denial, network latency/errors | Domain outcome and controlled diagnostic context |
This matrix is a placement aid, not a product feature list. The right location depends on which component has the data and which request paths exist.
Keep resource authorization in the service
A valid token proves an identity or credential, not permission to read a particular order, document, or account. OWASP recommends object-level authorization for each API operation that acts on a caller-supplied object identifier; function-level permissions also need enforcement. Treat gateway checks as a shared defense layer, not the only authorization check. Pass caller identity through a trusted, authenticated channel; do not trust unverified forwarded headers. Restrict backend access to intended paths and authenticate the gateway to backends separately.
Questions before moving a concern
Is the concern genuinely shared across routes or services? Centralization helps with shared TLS, WAF, or coarse throttling; service-specific policy in a shared gateway creates coupling.
Does the decision require business state such as ownership, balance, order status, or refund window? Keep it with the data-owning service.
Who defines partial failure and recovery? Shallow read composition may fit the gateway. Multi-step changes that need retries or compensation should be owned by an application service.
Will the shared tier become a bottleneck or release dependency? A gateway adds a hop and shared operational responsibility.
Are bypass routes, caller identity propagation, and internal callers covered?
A gateway can assemble a small read-only order summary. A service should own decisions about whether the order may change and coordinate payment or inventory updates. Choose by data ownership, security boundary, business meaning, and failure/release responsibility.
References
[API gateways - Azure Architecture Center](https://learn.microsoft.com/en-us/azure/architecture/microservices/design/gateway)
[Gateway Offloading pattern - Azure Architecture Center](https://learn.microsoft.com/en-us/azure/architecture/patterns/gateway-offloading)
[Gateway Aggregation pattern - Azure Architecture Center](https://learn.microsoft.com/en-us/azure/architecture/patterns/gateway-aggregation)
[OWASP API1:2023 Broken Object Level Authorization](https://api-security.owasp.org/editions/2023/en/0xa1-broken-object-level-authorization/)
[OWASP API5:2023 Broken Function Level Authorization](https://api-security.owasp.org/editions/2023/en/0xa5-broken-function-level-authorization/)