Overview

11 Authorization for APIs

APIs are the connective tissue of modern systems, but that makes them a major security boundary: they must be open enough to support communication while still preventing misuse. The chapter frames API authorization as two related problems: protecting internal service-to-service traffic and supporting external delegation to third-party applications. In both cases, the core challenge is to ensure that each request is checked against policy in a way that is consistent, fine-grained, and hard to bypass.

For internal microservices, ACME’s move away from a monolith exposed many new request paths, and authorization logic that was once centralized became fragmented across services. To fix this, the chapter compares three enforcement patterns: using the API gateway for edge traffic, using a service mesh with sidecar proxies for east-west traffic, and using per-service proxies for legacy or transitional APIs. These patterns differ operationally, but all of them normalize requests into a common decision format and send them to Cedar, which becomes the policy decision point. The examples emphasize avoiding confused deputy problems by making decisions based on the true principal, resource, action, and context rather than simply trusting the calling service.

For external access, OAuth solves the password anti-pattern by letting users or organizations grant limited, revocable access to applications through scopes and tokens. The chapter contrasts the Authorization Code Grant, used when a person like Kate explicitly consents to a tool such as BI Explorer, with the Client Credentials Grant, used for headless integrations like CustCo’s Task App. OAuth provides the delegation boundary, but Cedar still makes the final authorization decision for each request, allowing ACME to combine broad delegation with precise business rules. The overall message is that API security works best when delegation and policy enforcement are layered together, giving both flexibility for integration and strict control over sensitive data.

API Gateway as a centralized enforcement point. Carol’s request moves through the Manager Dashboard to the HR API. The API Gateway functions as the PEP, forwarding a normalized PARC request to the Cedar engine (PDP). The HR API receives the call only if Cedar returns an allow decision.
Service mesh enforcement with sidecars. Cedar evaluates each document sent from Docs to Search. Documents tagged "Legal" are denied; others are allowed.
Per-service proxy enforcement. The Finance API is not yet part of the service mesh, so ACME places a proxy directly in front of it. The proxy validates caller identity, constructs a Cedar authorization request, and forwards the call only if Cedar allows it.
OAuth roles in action. Kate is the resource owner, BI Explorer is the client, ACME’s Customer Authentication Service is the authorization server, and the Customer Collaboration API is the resource server.
Authorization Code Grant. The resource owner’s browser handles login and consent. ACME’s authorization server provides a short-lived code, which the client then exchanges for an access token over a secure back channel.
 OAuth consent screen for BI Explorer. Kate reviews the scopes requested by BI Explorer. She grants permission to read workspace membership and view document metadata (but not content), and she does not allow BI Explorer to subscribe to updates. The token issued to BI Explorer will be limited to the scopes Kate selected.
 CustCo’s Task App authenticates to ACME’s authorization server using its client credentials and receives an access token that represents the app (an integration principal). Admin setup and the installation record bind the app to CustCo and specific workspaces.
Using an OAuth token with Cedar. The client (BI Explorer or Task App) includes an access token in its API request. The API gateway validates the token and then creates a PARC request for Cedar. The request proceeds to the Customer Collaboration API and returns data only if Cedar grants permission.

Summary

  • ACME secures APIs on two fronts: Cedar policies safeguard internal micro­services at gateways, meshes, and proxies, while OAuth tokens, combined with Cedar, allow safe external delegation to customer applications.
  • API authorization works best when each request path has a clear enforcement point that can validate identity, gather context, invoke policy, enforce the decision, and log the result.
  • ACME enforces internal policies using gateway, service mesh, and per-service proxy patterns, with Cedar serving as the decision engine.
  • OAuth enables delegated access without sharing passwords, with scopes specifying which APIs a token bearer can access.
  • The Authorization Code Grant (Kate’s BI Explorer) and Client Credentials Grant (CustCo’s Task App) demonstrate the two most important methods for obtaining tokens.
  • Regardless of grant type, tokens are validated at the gateway and then converted into PARC requests for Cedar, which enforces detailed access control.

FAQ

What is the main challenge of authorization for APIs in a microservices environment?APIs in microservices create many service boundaries, so authorization can no longer live in one monolith. The challenge is to enforce consistent, fine-grained rules across many APIs and traffic paths without duplicating logic or leaving gaps.
Why is an API gateway useful as an authorization enforcement point?An API gateway is useful because it already sits in front of incoming north–south traffic. It can centralize enforcement, normalize requests, consult the policy engine, and block unauthorized calls before they reach backend services.
What limitation does the API gateway pattern have for authorization?The gateway only sees traffic that passes through it. It does not cover all east–west service-to-service calls inside the system, so internal requests can bypass gateway-only enforcement.
How does a service mesh improve API authorization?A service mesh places a sidecar proxy in front of each service-to-service call. This lets the system authenticate workloads with mTLS, gather request context, and enforce policy at every internal hop.
What role does SPIFFE play in service-to-service authorization?SPIFFE provides strong cryptographic workload identity. It helps a proxy know which service is making the call, while Cedar decides whether that authenticated workload is allowed to perform the requested action.
What are per-service proxies, and when are they used?Per-service proxies are lightweight enforcement layers placed directly in front of a specific API. They are useful for legacy services, transitional systems, or critical APIs that are not yet covered by the gateway or service mesh.
What is the confused deputy problem in API authorization?The confused deputy problem occurs when a legitimate component is tricked into using its authority on behalf of someone who should not have it. In the chapter’s examples, the request must be authorized based on the real principal behind it, not just the service making the call.
How does OAuth support delegated access without sharing passwords?OAuth lets a user approve limited access for a third-party application through scopes, without giving the app their password. The app receives a token that represents the approved delegation and can be revoked later.
What is the difference between the Authorization Code Grant and the Client Credentials Grant?The Authorization Code Grant is used when a person consents to an app accessing their data, while the Client Credentials Grant is used for service-to-service or app-to-app access. The first represents a user-delegated grant; the second represents an integration principal acting as itself.
Why are OAuth scopes not enough by themselves for API authorization?Scopes define broad access boundaries, but they do not answer fine-grained questions like which specific resource can be accessed or whether sensitivity labels apply. Cedar is needed to evaluate the detailed policy for each request.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Authorization in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Authorization in Action ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Authorization in Action ebook for free