Course contentsShow
← System Design
Lesson 943 of 1,91924. Authentication and Authorization at ScaleFree lesson

Authorization in Microservices

Distribute authorization across services or centralize in a policy service for consistency.

Authorization in Microservices

You'll learn: Where to implement authorization checks in a microservices architecture to balance consistency with performance.

The Core Challenge

In microservices, you face a fundamental tradeoff: should each service independently check permissions (distributed authorization), or should one central policy service make all decisions (centralized authorization)?

Think of it like security checkpoints at a campus. You could have distributed checkpoints at every building entrance where guards independently verify ID badges, or a central security office that all buildings call before granting access.

Distributed Authorization

Each microservice owns its authorization logic and makes decisions locally:

Order Service checks: "Can user X place orders?"
Inventory Service checks: "Can user X view inventory?"

Pros: Fast (no network call), resilient (no single point of failure), service autonomy
Cons: Policy inconsistency, duplication, harder to audit

Centralized Authorization

Services delegate decisions to a dedicated policy service (like Open Policy Agent):

Order Service → Policy Service: "Can user X place orders?"
← Response: Allow/Deny

Pros: Consistent policies, easier auditing, centralized updates
Cons: Extra network hop, potential bottleneck, dependency risk

The Hybrid Approach

Many systems use both: centralize complex, cross-cutting policies (RBAC/ABAC rules) but cache authorization decisions locally and let services enforce service-specific rules independently.

Key Takeaway: Authorization in microservices requires choosing between distributed autonomy and centralized consistency—most systems use caching and policy decision points (PDPs) to achieve both, avoiding the single-point-of-failure while maintaining consistent access control across services.