[PR #8410] [CLOSED] fix(oauth-provider): use pairwise sub in JWT access tokens (RFC 9068 §6) #24857

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

📋 Pull Request Information

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

Base: canaryHead: feat/pairwise-jwt-access-token-sub


📝 Commits (1)

  • 6f73641 feat(oauth-provider): use pairwise sub in JWT access tokens (RFC 9068 §6)

📊 Changes

3 files changed (+38 additions, -5 deletions)

View changed files

📝 docs/content/docs/plugins/oauth-provider.mdx (+2 -1)
📝 packages/oauth-provider/src/pairwise.test.ts (+30 -3)
📝 packages/oauth-provider/src/token.ts (+6 -1)

📄 Description

Follow-up to #8292

Missed applying pairwise sub resolution to JWT access tokens.

RFC 9068 §6 recommends that "the authorization server SHOULD ensure that JWT access tokens meant for different resource servers have distinct sub values that cannot be correlated." The pairwise PR only applied resolveSubjectIdentifier to id_tokens, userinfo, and introspection; JWT access tokens still used the raw user.id.

This applies the same pairwise resolution to createJwtAccessToken. Public clients are unaffected.


Summary by cubic

Apply pairwise subject identifiers to JWT access tokens per RFC 9068 §6 to prevent cross-resource correlation. Public clients are unchanged and still use user.id as sub.

  • Bug Fixes
    • Sign JWT access tokens with resolveSubjectIdentifier instead of user.id.
    • Tests: ensure access token sub matches id_token for pairwise clients, differs across sectors, and remains user.id for public clients.
    • Docs: note pairwise sub applies to JWT access tokens; clarify public client behavior.

Written for commit 6f73641ed0. Summary will update on new commits.


🔄 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/8410 **Author:** [@gustavovalverde](https://github.com/gustavovalverde) **Created:** 3/5/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/pairwise-jwt-access-token-sub` --- ### 📝 Commits (1) - [`6f73641`](https://github.com/better-auth/better-auth/commit/6f73641ed03e4cd0c891eb10007382ef088c9950) feat(oauth-provider): use pairwise sub in JWT access tokens (RFC 9068 §6) ### 📊 Changes **3 files changed** (+38 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/oauth-provider.mdx` (+2 -1) 📝 `packages/oauth-provider/src/pairwise.test.ts` (+30 -3) 📝 `packages/oauth-provider/src/token.ts` (+6 -1) </details> ### 📄 Description Follow-up to #8292 Missed applying pairwise `sub` resolution to JWT access tokens. RFC 9068 §6 recommends that "the authorization server SHOULD ensure that JWT access tokens meant for different resource servers have distinct `sub` values that cannot be correlated." The pairwise PR only applied `resolveSubjectIdentifier` to id_tokens, userinfo, and introspection; JWT access tokens still used the raw `user.id`. This applies the same pairwise resolution to `createJwtAccessToken`. Public clients are unaffected. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Apply pairwise subject identifiers to JWT access tokens per RFC 9068 §6 to prevent cross-resource correlation. Public clients are unchanged and still use user.id as sub. - **Bug Fixes** - Sign JWT access tokens with resolveSubjectIdentifier instead of user.id. - Tests: ensure access token sub matches id_token for pairwise clients, differs across sectors, and remains user.id for public clients. - Docs: note pairwise sub applies to JWT access tokens; clarify public client behavior. <sup>Written for commit 6f73641ed03e4cd0c891eb10007382ef088c9950. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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:35:42 -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#24857