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

Closed
opened 2026-04-15 22:41:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8634
Author: @gustavovalverde
Created: 3/16/2026
Status: Closed

Base: mainHead: feat/oauth-provider-at-hash


📝 Commits (1)

  • 06cf44b feat(oauth-provider): pass accessToken to customIdTokenClaims for at_hash

📊 Changes

2 files changed (+285 additions, -16 deletions)

View changed files

📝 packages/oauth-provider/src/token.test.ts (+233 -1)
📝 packages/oauth-provider/src/token.ts (+52 -15)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8634 **Author:** [@gustavovalverde](https://github.com/gustavovalverde) **Created:** 3/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/oauth-provider-at-hash` --- ### 📝 Commits (1) - [`06cf44b`](https://github.com/better-auth/better-auth/commit/06cf44b4d5912e2f011a071c9b860fae47f6aa24) feat(oauth-provider): pass accessToken to customIdTokenClaims for at_hash ### 📊 Changes **2 files changed** (+285 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/oauth-provider/src/token.test.ts` (+233 -1) 📝 `packages/oauth-provider/src/token.ts` (+52 -15) </details> ### 📄 Description ## 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:41:17 -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#25007