Authentication and API security

Validate OpenID Connect ID tokens correctly

Check issuer, audience, nonce, signature and time claims when validating OpenID Connect ID tokens. An ID token asserts an authentication event to a client; it is not an API access token. Accepting a token without validating its issuer and intended audience can authenticate the wrong identity or application. Security controls depend on client type, data sensitivity and deployment context; verify provider and standards guidance before production changes.

Threat model and trust boundaries

An ID token asserts an authentication event to a client; it is not an API access token. Accepting a token without validating its issuer and intended audience can authenticate the wrong identity or application.

  • Identify actors, assets and trust boundaries
  • Choose controls that address the stated threat
  • Test failure behavior and recovery paths

Implementation approach

Use the provider's trusted discovery metadata and key set, allow-list algorithms, validate iss and aud (including azp where required), check exp and iat with bounded clock skew, and compare nonce to the login request.

  • Confirm the responsible owner
  • Apply the change to a representative case
  • Document decisions and exceptions

Practical example

A relying party rejects a correctly signed ID token issued for a different client because its audience does not contain the application's registered client ID.

  • Reproduce the starting situation
  • Apply the described approach
  • Check the user-facing result

Verification and follow-up

Add tests for wrong issuer, wrong audience, expired token, nonce mismatch, unknown key and key rotation; confirm account identity uses the stable subject claim in the issuer context.

  • Test expected and failure cases
  • Compare with the recorded baseline
  • Agree the next review date and owner

Questions to keep in view

When should a team use this authentication and api security guide?

Check issuer, audience, nonce, signature and time claims when validating OpenID Connect ID tokens.

What should be checked before rollout?

Add tests for wrong issuer, wrong audience, expired token, nonce mismatch, unknown key and key rotation; confirm account identity uses the stable subject claim in the issuer context.