OIDC, Token Audiences, and Scopes
Separate ID tokens from access tokens and enforce issuer, audience, purpose, granted scope, and end-user delegation.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
An authentic token can be the wrong token
OpenID Connect adds an identity layer to OAuth. An ID token tells a client about an authentication event under a defined validation profile. An access token is presented to a resource API under that API's profile. They have different recipients and purposes even if both happen to be JWTs signed by the same issuer.
Imagine a company with Notes API and Billing API. The authorization server issues a signed token for Notes. Billing also trusts that issuer, but must reject a Notes token as a Billing credential. Without audience validation, a token issued for a less sensitive service can be substituted into another service.
{
"iss": "https://identity.example.test/",
"sub": "member-7",
"aud": "notes-api",
"scope": "notes:read",
"exp": 2000000000
}
The signature and expiry can both be correct. The first question is whether Billing accepts notes-api as its intended recipient. The next is whether the granted permissions authorize the Billing operation. Do not collapse audience and scope into one string comparison.