[PR #6091] [CLOSED] feat(sso): private_key_jwt client assertion #32039

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6091
Author: @EnzoAlbornoz
Created: 11/19/2025
Status: Closed

Base: canaryHead: feature/client_assertion_private_key_jwt


📝 Commits (5)

📊 Changes

6 files changed (+299 additions, -40 deletions)

View changed files

📝 packages/core/src/oauth2/client-credentials-token.ts (+59 -6)
📝 packages/core/src/oauth2/oauth-provider.ts (+25 -0)
📝 packages/core/src/oauth2/refresh-access-token.ts (+59 -5)
📝 packages/core/src/oauth2/validate-authorization-code.ts (+71 -17)
📝 packages/sso/src/routes/sso.ts (+67 -9)
📝 packages/sso/src/types.ts (+18 -3)

📄 Description

Closes #5935


Summary by cubic

Add private_key_jwt support for SSO token requests. Token exchanges can now use a signed client assertion instead of a client secret in auth code, refresh token, and client credentials flows.

  • New Features

    • Support "private_key_jwt" in tokenEndpointAuthentication and generate a client_assertion (audience = token endpoint, 5 min expiry, configurable alg; default RS256).
    • Add clientPrivateKey, clientPrivateKeyId, clientPrivateKeyType (jwk | pkcs8), and clientPrivateKeyAlg to provider options and OIDC config; propagate through SSO routes.
    • Enable private_key_jwt for authorization code, refresh token, and client credentials flows.
  • Migration

    • To use private_key_jwt, set tokenEndpointAuthentication to "private_key_jwt" and provide clientPrivateKey (JWK JSON or PKCS8 string); set clientPrivateKeyType, optional clientPrivateKeyAlg, and optional clientPrivateKeyId; omit clientSecret.
    • No changes needed for client_secret_post or client_secret_basic.

Written for commit f81c72d49a. Summary will update automatically 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/6091 **Author:** [@EnzoAlbornoz](https://github.com/EnzoAlbornoz) **Created:** 11/19/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feature/client_assertion_private_key_jwt` --- ### 📝 Commits (5) - [`dda11e5`](https://github.com/better-auth/better-auth/commit/dda11e5552350a204e12dffaa6c4eb4ebbf55e0f) feat(sso): prototype for private_key_jwt client assertion - [`fa85e40`](https://github.com/better-auth/better-auth/commit/fa85e408ffcf2e7602e47c93898ab0cbb8a4797f) feat(sso): add support for private keys in pkcs8 and different algorithms - [`43e5502`](https://github.com/better-auth/better-auth/commit/43e5502c3a71697393603fb4cf726da0d1786e66) Merge branch 'canary' of https://github.com/better-auth/better-auth into feature/client_assertion_private_key_jwt - [`ebdeda5`](https://github.com/better-auth/better-auth/commit/ebdeda5bca2ea2fcb013c7cb05666319451c5d56) feat(core,sso): add support for specifying private key id - [`f81c72d`](https://github.com/better-auth/better-auth/commit/f81c72d49a7950a5fd8c5b68baa88e709ad65564) Merge branch 'canary' of https://github.com/better-auth/better-auth into feature/client_assertion_private_key_jwt ### 📊 Changes **6 files changed** (+299 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/oauth2/client-credentials-token.ts` (+59 -6) 📝 `packages/core/src/oauth2/oauth-provider.ts` (+25 -0) 📝 `packages/core/src/oauth2/refresh-access-token.ts` (+59 -5) 📝 `packages/core/src/oauth2/validate-authorization-code.ts` (+71 -17) 📝 `packages/sso/src/routes/sso.ts` (+67 -9) 📝 `packages/sso/src/types.ts` (+18 -3) </details> ### 📄 Description Closes #5935 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add private_key_jwt support for SSO token requests. Token exchanges can now use a signed client assertion instead of a client secret in auth code, refresh token, and client credentials flows. - **New Features** - Support "private_key_jwt" in tokenEndpointAuthentication and generate a client_assertion (audience = token endpoint, 5 min expiry, configurable alg; default RS256). - Add clientPrivateKey, clientPrivateKeyId, clientPrivateKeyType (jwk | pkcs8), and clientPrivateKeyAlg to provider options and OIDC config; propagate through SSO routes. - Enable private_key_jwt for authorization code, refresh token, and client credentials flows. - **Migration** - To use private_key_jwt, set tokenEndpointAuthentication to "private_key_jwt" and provide clientPrivateKey (JWK JSON or PKCS8 string); set clientPrivateKeyType, optional clientPrivateKeyAlg, and optional clientPrivateKeyId; omit clientSecret. - No changes needed for client_secret_post or client_secret_basic. <sup>Written for commit f81c72d49a7950a5fd8c5b68baa88e709ad65564. Summary will update automatically 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-17 22:54:34 -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#32039