The idea: OAuth hands out a key, OpenID Connect says who you are

OAuth 2.0 lets an app act for a user: the app gets an access token that an API accepts. That is authorization: what the holder may do. It does not tell the app who the user is. OpenID Connect (OIDC) is a thin layer on top of OAuth that adds authentication: who signed in. It adds one scope, openid, and one token, the ID token, a signed statement made for the app itself. Every "Sign in with …" button works this way.

A sequence diagram between alice's browser, notes.example (the relying party) and id.example (the OpenID provider). 1 to 2: redirect to /authorize through the browser. 3: login and consent at id.example. 4 to 5: redirect back to /cb with the code. 6: POST /token with the code and code_verifier, server to server. 7: access_token and id_token come back. 8: the RP checks the ID token. 9 to 10: GET /userinfo with the access token returns the profile. Front-channel steps are orange, back-channel steps blue.
Only the code passes through the browser; both tokens travel server to server, and the ID token is checked before anyone is signed in.

The canvas has three parties. alice's browser (with Eve, an attacker, under it), the app she signs in to, notes.example, called the relying party (RP), and id.example, the OpenID provider (OP), which knows her password. Under them are the ID token the RP holds and the five checks it makes on it. Orange boxes travel through the browser (the front channel), blue boxes go straight from server to server (the back channel), red ones are Eve's.

The authorization code flow with PKCE

OIDC uses the same authorization code flow as OAuth (Demo: sign in with OpenID Connect):

  1. alice clicks "Sign in with id.example". The RP makes three random values and keeps them in her session: state (st-4Fq2), nonce (n-9xKp) and the PKCE code_verifier (cv-T8wqLm).
  2. It redirects the browser to /authorize?response_type=code&scope=openid profile email&client_id=notes-web&redirect_uri=…&state=…&nonce=…&code_challenge=…&code_challenge_method=S256. The challenge is BASE64URL(SHA-256(code_verifier)); the verifier itself stays on the RP.
  3. id.example checks the client and its exact redirect_uri, asks for the password (only id.example ever sees it) and shows a consent page: "notes.example wants your name and email".
  4. On Allow it redirects back to https://notes.example/cb?code=c-Q7dR&state=st-4Fq2. The code is valid for a short time, once, and is tied to notes-web, the redirect URI, the challenge and the nonce.
  5. The RP checks state, then calls the token endpoint itself: POST /token with grant_type=authorization_code, the code, the redirect URI, the code_verifier and its client credentials.
  6. id.example checks that SHA-256 of the verifier equals the stored challenge and returns {"access_token", "id_token", "token_type": "Bearer", "expires_in": 3600}.

PKCE makes a stolen code useless: whoever catches it in a redirect does not have the verifier. The OAuth page shows that attack, and CSRF on the callback, which state stops.

The ID token

The ID token is a JWT (JSON Web Token): three base64url parts joined by dots, header.payload.signature. The header names the algorithm and the key ("alg": "RS256", "kid": "k1"). The payload is a set of claims:

ClaimMeaningOn the canvas
ississuer: who made the tokenhttps://id.example
subsubject: the user's stable id at that issuer248289761001
audaudience: the client the token is fornotes-web
exp, iatexpiry and issue time (seconds since 1970; shown as clock times)iat + 1 h
noncethe value the RP sent in this sign-in's request, echoed backn-9xKp

The signature is made with id.example's private key. Anyone can check it with the matching public key, which id.example publishes as a JWKS (JSON Web Key Set) at its jwks_uri; the kid says which key to use. See Digital Signatures.

An ID token split into header, payload and signature. Arrows lead from each part to a check: iss equals https://id.example, aud contains notes-web, the signature verifies with key k1 from the JWKS, exp is in the future, nonce equals the session's nonce. Each check is labelled with the fake it stops: another provider, a token for another app, an edited payload, an old token, a replay from another sign-in.
Five checks, five different fakes: each claim is only worth something once the RP has checked it.

Checking the ID token

OIDC Core section 3.1.3.7 lists what the RP must check before it believes the token. The page shows the five that matter most, in the spec's order. Each one stops a different token Eve can bring:

CheckStopsDemo
1 iss is the expected providera token from Eve's own provider, id.evil.exampleforged tokens
2 aud contains this client_ida genuine token about alice that was made for another appplain OAuth login vs ID token
3 signature verifies with a JWKS keya token whose payload was edited (sub changed)forged tokens
4 exp is in the futurean old token copied from a logreplayed tokens
5 nonce equals the session's noncea still-valid token from a different sign-inreplayed tokens

In the code flow the ID token comes straight from the token endpoint over TLS, so the spec lets the RP trust the TLS connection instead of the signature. Libraries check the signature anyway, and it is required for an ID token that arrives any other way, such as the /login endpoint Eve uses here (mobile apps often send the ID token to their back end like this). After the checks, the pair (iss, sub) is the user's identity: it never changes, unlike the email address.

userinfo and the access token

The access token has its own job. The RP sends it as Authorization: Bearer at-M2v9 to the userinfo endpoint, an OAuth-protected API that returns profile claims for the granted scopes (profile gives name, email gives email). The response's sub must equal the ID token's sub. Then the RP starts its own session with a cookie and stops using the tokens to recognise alice (JWT vs session cookies).

Why an access token is not a login

Before OIDC, many apps did "log in with OAuth": get an access token, call a profile API, sign in whoever it names. The access token was never meant for the app: it carries no audience the app checks. So any token for alice works, including one that alice once gave to an unrelated app (Demo: plain OAuth login vs ID token). Eve runs quiz.example; alice once signed in there, so Eve has alice's access token. She posts it to the plain-OAuth notes.example, /userinfo truthfully answers "this is alice", and Eve is signed in as alice. With OIDC Eve can only bring the ID token made for quiz-app, and check 2 refuses it.

Two panels. Left, plain OAuth: Eve posts alice's access token at-Qz31 from quiz.example to notes.example, which calls /userinfo, gets sub alice and signs Eve in as alice, marked with a cross. Right, OpenID Connect: Eve posts the ID token with aud quiz-app, notes.example checks aud against notes-web and refuses, marked with a tick.
The access token answers "may the bearer read alice's profile?"; only the ID token answers "did alice sign in to this app?".
Access token (OAuth)ID token (OIDC)
Answerswhat may the bearer dowho signed in, when, at which provider
Meant forthe API (resource server)the client app (aud = client_id)
Formatopaque string or JWT, the client must not rely on italways a signed JWT
Sent to APIsyes, as Bearerno

Discovery and keys

An RP finds everything about a provider at https://id.example/.well-known/openid-configuration: the issuer, authorization_endpoint, token_endpoint, userinfo_endpoint and jwks_uri. It caches the JWKS. When the provider rotates its signing key, it publishes the new key with a new kid first, so a token signed with an unknown kid makes the RP fetch the JWKS again. Compare Kerberos, where single sign-on inside one network uses symmetric keys shared with the KDC instead of public keys, and passkeys, which can replace the password at the provider.

See also How SAML Single Sign-On Works for the older XML-based single sign-on, with Audience, NotOnOrAfter and InResponseTo in place of aud, exp and nonce.

What the page leaves out

  • Real cryptography: codes, hashes and signatures are short fake strings, and TLS under every request is not drawn.
  • The other ID token checks (azp with several audiences, iat limits, auth_time with max_age, acr), encrypted ID tokens, and the implicit and hybrid flows.
  • Refresh tokens, logout (RP-initiated, front- and back-channel logout), prompt and login_hint, dynamic client registration.
  • How the provider checks the password or a second factor, and the consent screen's remembered choices.

On the mind map

Open the Web & Security mind mapWeb & SecurityCrypto building blocks: keys, hashes, signaturesCrypto building blocksStoring passwords: slow salted hash, never plaintextStoring passwordsBrowser rules: which request carries whatBrowser rulesRequest attacks: trick a browser or a serverRequest attacksLogin & identity: prove who you areLogin & identityOWASP Top 10 2025: common flaws, then the fixOWASP Top 10 2025OWASP: supply chain & ops: dependencies, logs and error pathsOWASP: supply chain & opsOAuth 2.0 with PKCEOAuth 2.0 with PKCEapp gets a scoped token, not the passwordOpenID ConnectID token says who; check iss, aud, nonceSAML Single Sign-OnSAML Single Sign-OnSP checks the IdP's signed assertionJWT vs session cookieJWT vs session cookieJWT: signed, stateless, hard to revokeKerberosKerberosTGT from the KDC, then a ticket per serviceLDAP directoryLDAP directorySearch for the DN, then bind as the userMutual TLSMutual TLSboth sides show and prove a certificateEmail SPF, DKIM, DMARCEmail SPF, DKIM, DMARCDMARC: SPF or DKIM must align with From:TOTP two-factor codesTOTP two-factor codesHMAC(secret, time/30s) → 6 digitsRBAC vs ABACRBAC vs ABACRoles grant rights; attributes decide liveBell-LaPadula and BibaBell-LaPadula and BibaNo read up, no write down; Biba flips itGRANT and REVOKEGRANT and REVOKEMariaDB REVOKE never cascadesOpen the Web & Security mind mapWeb & Securityprove who you areLogin & identityOAuth 2.0 with PKCEOAuth 2.0 with PKCEapp gets a scoped token, not the passwordOpenID ConnectID token says who; check iss, aud, nonceSAML Single Sign-OnSAML Single Sign-OnSP checks the IdP's signed assertionJWT vs session cookieJWT vs session cookieJWT: signed, stateless, hard to revokeKerberosKerberosTGT from the KDC, then a ticket per serviceLDAP directoryLDAP directorySearch for the DN, then bind as the userMutual TLSMutual TLSboth sides show and prove a certificateEmail SPF, DKIM, DMARCEmail SPF, DKIM, DMARCDMARC: SPF or DKIM must align with From:TOTP two-factor codesTOTP two-factor codesHMAC(secret, time/30s) → 6 digitsRBAC vs ABACRBAC vs ABACRoles grant rights; attributes decide liveBell-LaPadula and BibaBell-LaPadula and BibaNo read up, no write down; Biba flips itGRANT and REVOKEGRANT and REVOKEMariaDB REVOKE never cascades
This page on the Web & Security mind map · 45 pages in 7 branches · open it to see the whole map and test yourself in recall mode.