[PR #7816] [MERGED] fix(sso): validate aud claim in OpenID Connect ID tokens #15818

Closed
opened 2026-04-13 10:14:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7816
Author: @Paola3stefania
Created: 2/5/2026
Status: Merged
Merged: 2/6/2026
Merged by: @himself65

Base: canaryHead: fix/sso-validate-id-token-audience


📝 Commits (5)

  • 95a10e5 verify aud and issuer
  • b29c228 Merge branch 'canary' into fix/sso-validate-id-token-audience
  • 71ef485 use the validate funciton
  • 3cc2f53 use create remote jws set
  • a564391 make lint happy

📊 Changes

3 files changed (+134 additions, -78 deletions)

View changed files

📝 packages/core/src/oauth2/validate-authorization-code.ts (+13 -21)
📝 packages/core/src/oauth2/validate-token.test.ts (+117 -50)
📝 packages/sso/src/routes/sso.ts (+4 -7)

📄 Description

Summary by cubic

Validate the audience and issuer in OpenID Connect ID tokens during SSO to ensure tokens are intended for our client and provider. Prevents accepting tokens minted for the wrong audience or issuer.

  • Bug Fixes
    • validateToken now accepts audience and issuer and passes them to jwtVerify.
    • Switched to jose createRemoteJWKSet for JWKS validation; removes manual key selection.
    • SSO callback verifies ID token with config.clientId and provider.issuer; tests cover aud/iss and key mismatch.

Written for commit a564391583. 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/7816 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 2/5/2026 **Status:** ✅ Merged **Merged:** 2/6/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/sso-validate-id-token-audience` --- ### 📝 Commits (5) - [`95a10e5`](https://github.com/better-auth/better-auth/commit/95a10e51e2b4105f8f0efd3ca32afe2e6943551c) verify aud and issuer - [`b29c228`](https://github.com/better-auth/better-auth/commit/b29c2289a703da89a04bd5414060960e16e77332) Merge branch 'canary' into fix/sso-validate-id-token-audience - [`71ef485`](https://github.com/better-auth/better-auth/commit/71ef4856514c3d198187d0c652b254308d50b6bd) use the validate funciton - [`3cc2f53`](https://github.com/better-auth/better-auth/commit/3cc2f53aea7babb5e675560da8c8727b69f17ed8) use create remote jws set - [`a564391`](https://github.com/better-auth/better-auth/commit/a564391583eeb4fbd9e69158eb975d9d1e15f1d8) make lint happy ### 📊 Changes **3 files changed** (+134 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/oauth2/validate-authorization-code.ts` (+13 -21) 📝 `packages/core/src/oauth2/validate-token.test.ts` (+117 -50) 📝 `packages/sso/src/routes/sso.ts` (+4 -7) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Validate the audience and issuer in OpenID Connect ID tokens during SSO to ensure tokens are intended for our client and provider. Prevents accepting tokens minted for the wrong audience or issuer. - **Bug Fixes** - validateToken now accepts audience and issuer and passes them to jwtVerify. - Switched to jose createRemoteJWKSet for JWKS validation; removes manual key selection. - SSO callback verifies ID token with config.clientId and provider.issuer; tests cover aud/iss and key mismatch. <sup>Written for commit a564391583eeb4fbd9e69158eb975d9d1e15f1d8. 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-13 10:14:35 -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#15818