All guides

OpenID Connect for engineers: tokens, claims and trust

OpenID Connect is an identity layer on top of OAuth 2.0. A provider authenticates the user and issues a signed ID token, and the application validates that token before it uses any claim.

A pair of glasses in front of two screens showing code

The three parties

  • The subject. In a sign-in this is a person, whom the specification calls the End-User. GitHub's OIDC provider issues a token that identifies a workflow job.
  • The identity provider. The specification calls it the OpenID Provider: an OAuth 2.0 authorization server that authenticates the End-User and provides claims about that authentication.
  • The relying party. The application that requires the authentication and the claims. In OAuth 2.0 terms it is the client.

ID token and access token

In the authorization code flow, the provider's token endpoint returns an ID token and an access token.

The ID token is a JSON Web Token (JWT) with claims about the authentication event: the issuer, the subject, the audience and an expiration time. It must be signed, and its audience must contain the relying party's client_id.

The access token is different. RFC 6749 defines it as a credential used to access protected resources.

The discovery document and JWKS

A provider that supports discovery publishes its configuration as JSON at the issuer URL followed by /.well-known/openid-configuration. GitHub's OIDC provider for Actions has one:

Shell

curl https://token.actions.githubusercontent.com/.well-known/openid-configuration

Three fields from that response:

JSON

{
  "issuer": "https://token.actions.githubusercontent.com",
  "jwks_uri": "https://token.actions.githubusercontent.com/.well-known/jwks",
  "id_token_signing_alg_values_supported": ["RS256"]
}

issuer must be identical to the URL you used to fetch the document and to the iss claim in ID tokens from that issuer. jwks_uri is the address of the JSON Web Key Set, which holds the keys a relying party uses to validate signatures.

For key rotation, the specification has the provider put the kid of the signing key in each token's header and add new keys to the set. A verifier that sees an unfamiliar kid retrieves the keys from jwks_uri again.

The claims a relying party checks

The specification lists what a client must validate in an ID token. The signature is validated with the keys provided by the issuer, and alg should be RS256 or the algorithm the client registered. For a token received directly from the token endpoint, TLS server validation may take the place of the signature check.

Then come five claims:

  • iss must exactly match the provider's issuer identifier.
  • aud must contain your client_id. Reject a token that lists audiences you do not trust.
  • exp: the current time must be before it. Implementers may allow some small leeway for clock skew.
  • nonce: if you sent one in the request, the claim must be present with the same value.
  • sub is the subject identifier, locally unique and never reassigned within the issuer.

Store users by the pair of iss and sub. The specification says those two together are the only claims a relying party can rely on as a stable identifier, and that email and name must not be used as unique identifiers.

The authorization code flow with PKCE

OpenID Connect Core lists the flow in eight steps. The client sends an authentication request to the authorization server. The server authenticates the End-User, obtains consent and sends the End-User back with an authorization code. The client presents the code at the token endpoint, receives an ID token and an access token, and validates the ID token.

The specification's own request, with line wraps for display:

Text

GET /authorize?
    response_type=code
    &scope=openid%20profile%20email
    &client_id=s6BhdRkqt3
    &state=af0ifjsldkj
    &redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb HTTP/1.1
Host: server.example.com

scope must contain openid. state is recommended, and nonce is optional.

PKCE is defined in RFC 7636. The client creates a code_verifier, a high-entropy random string, and derives a code_challenge from it. With the S256 method the challenge is the base64url-encoded SHA-256 hash of the verifier. The client sends code_challenge and code_challenge_method with the authorization request and code_verifier with the token request. The server denies access if the transformed verifier differs from the challenge, so an attacker who intercepts the code cannot redeem it.

RFC 9700 requires PKCE for public clients and recommends it for confidential clients.

Workloads in CI

On GitHub Actions, a job with the id-token: write permission requests a JWT from GitHub's OIDC provider, and the token is unique to that job. Its iss is https://token.actions.githubusercontent.com.

By default, GitHub builds sub from metadata such as the organization, the repository, the branch or the job's environment. For a branch the syntax is repo:ORG-NAME/REPO-NAME:ref:refs/heads/BRANCH-NAME. Repositories created after 15 July 2026 use a format that also includes the owner ID and the repository ID.

The job presents the token to the cloud provider, which checks the subject and the other claims against the conditions on the cloud role's trust definition. On a match it issues a short-lived access token, valid only while the job runs.

What to check in your setup

  1. Fetch the discovery document and confirm that issuer is identical to the issuer URL you configured.
  2. Confirm that your library performs each validation listed above.
  3. Send state, and send nonce and compare it in the ID token.
  4. Use PKCE with S256. RFC 7636 says a client that can use S256 must use it.
  5. For CI, define at least one condition on the cloud role. GitHub's documentation requires it so that untrusted repositories cannot request access tokens.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides