8. id_token — 7 checks & JWKS

11 cards

Review this deck
All cards in this deck

Check 1: signature

Fetch the public key from the JWKS endpoint by `kid`, verify with a whitelisted `alg` (RS256); do not trust the `alg` in the header.

Check 2: iss

Must equal the configured IdP issuer URL (differs between Auth0 and Keycloak).

Check 3: aud

Must contain the `client_id` of the client in use (`portal-web` or the corresponding step-up client).

Check 4: exp

The token must still be valid (`exp` > now, allowing a small clock skew of ~60s); an expired id_token is rejected even if the signature is valid.

Check 5: nonce

Equals the nonce stored in SessionID1.

Check 6: custom connection claim

`https://claims.example.com/connection` must belong to the set of valid connections for the client in use (e.g. `portal-web`: `Username-Password` or `Passkey-Login`); `usedPasskey = (connection == Passkey-Login)`.

Check 7: conditional auth_time

When sending `prompt=login&max_age=600` (only `max_age` guarantees the IdP issues the claim), `now - auth_time` must be ≤ 600s to be sure the user just re-authenticated.

Namespaced custom claims

Auth0 requires custom claims in URL form (`https://claims.example.com/account_no`) to avoid colliding with standard claims.

Where accountNo comes from

From a claim in the verified id_token, never from a query/body sent by the client.

JWKS cache

Cache by `kid` at boot and whenever a new `kid` appears; retry at most 2 times when fetching JWKS fails with 5xx/timeout.

alg=none attack

The library reads `alg` from the header and accepts `none` → an unsigned token still passes; prevent it with `algorithms: ['RS256']`.

8. id_token — 7 checks & JWKS – Flashcards – Login Flow | Học Dev