Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Trust boundaries

Every OAuth message arrives from somewhere its receiver does not control. The printer, the authorization server and the photo API each have to check what reaches them before acting on it, and no one's checks can stand in for another's.

Crossing a boundary

The point where information passes between components with different control or authority is a trust boundary. When Ava connects the printer, information crosses three of them: the authorization server's answer reaches the printer through Ava's browser, the printer's code reaches the authorization server, and the printer's token reaches the photo API. Each receiver asks its own questions, about its own decision from Roles and endpoints.

The printer receives the authorization response at its redirect URI. That address is public, and the response travels on the front channel, so anyone can make a browser open it with a code of their choosing. Receiving a request there proves nothing on its own. Before Ava's browser left, the printer generated a fresh random value called state, kept it with the pending attempt in Ava's session at the printer, and sent it in the authorization request. The authorization server returns it unchanged:

GET /oauth/callback?code=SplxlOBeZQQYbYS6WxSbIA&state=af0ifjsldkj&iss=https%3A%2F%2Fauth.photos.example HTTP/1.1
Host: printer.example

If state does not match the value stored for this browser's attempt, the printer discards the response: it answers no attempt that this browser started. The iss parameter names the authorization server that sent the response, in the URL encoding from Encoding and hashing. It matters when a client works with more than one authorization server, so a response from one is never taken for an answer from another. The printer checks it against the issuer it sent Ava to.

The authorization server has its own questions when the printer presents the code at the token endpoint. Is the redirect URI one registered for this client? Was this code issued to this client, and has it already been used or expired? Have the protections this exchange requires been satisfied, such as the one Public and confidential clients describes for clients that cannot keep a secret?

The photo API asks another set. Did an authorization server it trusts issue this token? Was the token intended for this API? Is it still usable? Does this request fall within the access granted, for this album?

Printing application

Authorization response

  • Expected authorization attempt?
  • Response matches the session?

Authorization server

Token request

code=ABC123

client_id=app123

redirect_uri=...

  • Registered redirect URI?
  • Code valid for this client?
  • Code unused and unexpired?

Photo API

API request

access_token=...

album_id=789

  • Trusted issuer and intended API?
  • Token still valid?
  • Access to this album allowed?
Examples of checks at separate trust boundaries, not a complete validation checklist. Checks at one boundary do not replace checks at another.

Protecting each request

The authorization server's decision to issue a token does not remove the API's responsibility to protect a particular album. The authorization server issued Ava's token without knowing which albums the printer would later ask for. Only the photo API sees that, request by request.

Suppose the printer, by a bug or by design, asks for album 4410, which belongs to Ava's friend Cora, using the token Ava approved:

GET /albums/4410 HTTP/1.1
Host: api.photos.example
Authorization: Bearer mF_9.B5f-4.1JqM

HTTP/1.1 404 Not Found
Content-Type: application/json

{"error": "not_found"}

The token is genuine, current and meant for this API, and it worked a moment ago for Ava's album 4420. The API still refuses, because Cora has not shared album 4410 with Ava. It answers 404, exactly as it would for an album that does not exist, so the refusal does not even reveal that the album is there. A valid token says who is asking and with what access; it is not permission to read whichever identifier appears in a URL. The API checks this person against this object on every request.

Checking a token is a separate step that comes first. Some access tokens are opaque: random-looking values with no readable content, whose meaning the API learns by asking the authorization server, a lookup called introspection. Others are signed JSON Web Tokens that the API checks itself. For a JWT, Digital signatures showed that the signature is only one part: the API also checks the issuer, the audience, the token type and the lifetime. A correctly signed token from the same authorization server, but addressed to another API, must be refused:

Decoded payload of the token the printer sent
{
  "iss": "https://auth.photos.example",
  "aud": "https://api.printlab.example",
  "scope": "photos.read"
}

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token"

The audience names the print lab's API, not the photo API, so the photo API refuses it before it looks at any album. Accepting it would let a token issued for one service be replayed at another.

Transport protection solves a different part of the problem. HTTPS protects these messages while they travel between two endpoints. It does not show that the printer was entitled to a particular album, that a code belongs to this client, or that an authorization response matches the browser session receiving it. Likewise, reading a token's contents does not establish that they are trustworthy. Each of those needs its own check, at the boundary where the decision is made.

After access is granted

There is one more boundary, after the photo API has said yes. Once the printer downloads Ava's photos, it holds copies. When Ava disconnects the printer, the photo service refuses its future requests, but that cannot make the copies already downloaded disappear. For those, Ava is trusting the printer itself: its storage, its retention and its promises about what it does with her photos.

These boundaries are why an OAuth integration needs more than a successful happy path. A connection where every message arrives as expected shows only that nothing went wrong this time. The checks show what happens when a response was never requested, a code was copied, or a token arrives at the wrong API. Later lessons introduce each set alongside the exchange it protects: the printer's in Correlating requests and responses, the authorization server's in Redirects and authorization codes and Exchanging a code for tokens, and the photo API's in Token formats and validation.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

The printer sends Ava's valid access token but asks for album 4410, which belongs to Cora and is not shared with Ava. What must the photo API do? 1 of 3

Choose one answer.

The printer's redirect URI receives a request over HTTPS carrying a code, but its state matches no attempt stored for this browser. What should the printer conclude? 2 of 3

Choose one answer.

A correctly signed token from the photo service's authorization server reaches the photo API, but its aud names https://api.printlab.example. What should the photo API do? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity