[PR #8634] feat(oauth-provider): compute at_hash in id tokens per OIDC Core §3.1.3.6 #16353

Open
opened 2026-04-13 10:30:04 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8634

State: open
Merged: No


Problem

OIDC Core §3.1.3.6 requires the at_hash claim in id_tokens when the token is issued alongside an access token from the authorization endpoint.

Changes

  • Compute at_hash server-side inside createIdToken — the access token is never exposed to customIdTokenClaims callbacks to prevent token leakage
  • Sequence id_token creation after access token creation so the access token string is available for hashing
  • Add computeOidcHash() that selects the correct hash algorithm based on the signing algorithm (EdDSA→SHA-512, RS/ES384→SHA-384, RS/ES512→SHA-512, else SHA-256)
  • Add base64url import from jose for the hash encoding

References

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8634 **State:** open **Merged:** No --- ## Problem OIDC Core §3.1.3.6 requires the `at_hash` claim in id_tokens when the token is issued alongside an access token from the authorization endpoint. ## Changes - Compute `at_hash` server-side inside `createIdToken` — the access token is never exposed to `customIdTokenClaims` callbacks to prevent token leakage - Sequence id_token creation after access token creation so the access token string is available for hashing - Add `computeOidcHash()` that selects the correct hash algorithm based on the signing algorithm (EdDSA→SHA-512, RS/ES384→SHA-384, RS/ES512→SHA-512, else SHA-256) - Add `base64url` import from `jose` for the hash encoding ## References - [OIDC Core §3.1.3.6 — ID Token `at_hash`](https://openid.net/specs/openid-connect-core-1_0.html#HybridIDToken)
GiteaMirror added the pull-request label 2026-04-13 10:30:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16353