[GH-ISSUE #5935] Support for client assertions (private_key_jwt) #10380

Open
opened 2026-04-13 06:29:13 -05:00 by GiteaMirror · 11 comments
Owner

Originally created by @EnzoAlbornoz on GitHub (Nov 12, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5935

Originally assigned to: @gustavovalverde, @Paola3stefania on GitHub.

Is this suited for github?

  • Yes, this is suited for github

RFC 7521: Assertion Framework for OAuth 2.0 Client Authentication and Authorization Grants introduced a new authentication type, private_key_jwt. This method is used by providers like Okta and is recommended for financial-grade APIs due to the increased security it provides with asymmetric keys.

Describe the solution you'd like

Include a new token authorization type called private_key_jwt (or pk as a shorthand) for validating authorization codes.

Describe alternatives you've considered

  • Using client secret: Financial-grade APIs are recommended to use private_key_jwt due to asymmetric key security features, so switching to it shouldn't be encouraged.
  • Rolling my own auth: Well, this is hard, isn't it 🥲?

Additional context

No response

Originally created by @EnzoAlbornoz on GitHub (Nov 12, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5935 Originally assigned to: @gustavovalverde, @Paola3stefania on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. RFC 7521: Assertion Framework for OAuth 2.0 Client Authentication and Authorization Grants introduced a new authentication type, private_key_jwt. This method is used by providers like Okta and is recommended for financial-grade APIs due to the increased security it provides with asymmetric keys. ### Describe the solution you'd like Include a new token authorization type called `private_key_jwt` (or `pk` as a shorthand) for validating authorization codes. ### Describe alternatives you've considered - Using client secret: Financial-grade APIs are recommended to use private_key_jwt due to asymmetric key security features, so switching to it shouldn't be encouraged. - Rolling my own auth: Well, this is hard, isn't it 🥲? ### Additional context _No response_
GiteaMirror added the oauthidentity labels 2026-04-13 06:29:13 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 12, 2025):

(tag @better-auth-agent if you would like an answer from the Agent)

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3523726074 --> @better-auth-agent[bot] commented on GitHub (Nov 12, 2025): (tag @better-auth-agent if you would like an answer from the Agent) <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@rovertrack commented on GitHub (Nov 14, 2025):

@better-auth-agent elaborate

<!-- gh-comment-id:3531280043 --> @rovertrack commented on GitHub (Nov 14, 2025): @better-auth-agent elaborate
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 14, 2025):

Thanks for your input on supporting client assertions with private_key_jwt. We understand that using asymmetric key security per RFC 7521 is particularly important for financial-grade APIs, and we’re actively evaluating how to incorporate a new token authorization type (or shorthand “pk”) into our framework to handle validation of authorization codes more securely [1]. Currently, better-auth relies on client secret–based methods, but we appreciate the suggestion to move toward a more robust, asymmetric approach.

Our next steps include reviewing the necessary standards and implementation details to ensure any changes remain backward compatible while enhancing security. In the meantime, could you please share any specific scenarios or requirements you’re encountering with your integration? Tag @bekacru or @ping__ if you’d like more in-depth insight from our team.

tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3531281544 --> @better-auth-agent[bot] commented on GitHub (Nov 14, 2025): Thanks for your input on supporting client assertions with private_key_jwt. We understand that using asymmetric key security per RFC 7521 is particularly important for financial-grade APIs, and we’re actively evaluating how to incorporate a new token authorization type (or shorthand “pk”) into our framework to handle validation of authorization codes more securely [[1]](https://github.com/better-auth/better-auth/issues/2000). Currently, better-auth relies on client secret–based methods, but we appreciate the suggestion to move toward a more robust, asymmetric approach. Our next steps include reviewing the necessary standards and implementation details to ensure any changes remain backward compatible while enhancing security. In the meantime, could you please share any specific scenarios or requirements you’re encountering with your integration? Tag @bekacru or @ping__ if you’d like more in-depth insight from our team. tag @better-auth-agent if you would like an answer from the Agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@mattss-madetech commented on GitHub (Nov 14, 2025):

I'm also interested in this feature, as I'm currently working on a project to integrate our Better Auth installation with the GOV.UK One Login service, a central authentication provider used across a number of UK government services.

At the moment we are only using it for authentication, which means we can temporarily use client_secret. However if we want to take advantage of their identity proving features in future, they require the additional security protections provided by private_key_jwt.

More details on GOV.UK One Login:

<!-- gh-comment-id:3531790829 --> @mattss-madetech commented on GitHub (Nov 14, 2025): I'm also interested in this feature, as I'm currently working on a project to integrate our Better Auth installation with the GOV.UK One Login service, a central authentication provider used across a number of UK government services. At the moment we are only using it for authentication, which means we can temporarily use `client_secret`. However if we want to take advantage of their identity proving features in future, they require the additional security protections provided by `private_key_jwt`. More details on GOV.UK One Login: * https://www.sign-in.service.gov.uk * https://docs.sign-in.service.gov.uk/before-integrating/integrating-third-party-platform/#set-up-client-secret-using-client-secret-post
Author
Owner

@rovertrack commented on GitHub (Nov 14, 2025):

@himself65 can we do this?

<!-- gh-comment-id:3532049745 --> @rovertrack commented on GitHub (Nov 14, 2025): @himself65 can we do this?
Author
Owner

@EnzoAlbornoz commented on GitHub (Nov 17, 2025):

Additional Docs here

Basically, instead of sending a client secret in the body, you would send a signed JWT that would be verified by the provider using your public key.

<!-- gh-comment-id:3543715185 --> @EnzoAlbornoz commented on GitHub (Nov 17, 2025): Additional Docs [here](https://oauth.net/private-key-jwt/) Basically, instead of sending a client secret in the body, you would send a signed JWT that would be verified by the provider using your public key.
Author
Owner

@EnzoAlbornoz commented on GitHub (Nov 19, 2025):

I've built a prototype of the client assertion in the SSO plugin. I needed to convert two functions from sync to async because jose handles JWT signing asynchronously.

I know there's still a lot to do, but I was able to make it work with Okta, so at least it works on the happy path.

<!-- gh-comment-id:3550908266 --> @EnzoAlbornoz commented on GitHub (Nov 19, 2025): [I've built a prototype of the client assertion in the SSO plugin](https://github.com/better-auth/better-auth/pull/6091). I needed to convert two functions from sync to async because `jose` handles JWT signing asynchronously. I know there's still a lot to do, but I was able to make it work with Okta, so at least it works on the happy path.
Author
Owner

@EnzoAlbornoz commented on GitHub (Nov 19, 2025):

Regarding #6053, it doesn't handle the use case I had in mind when I created this issue. This issue is more about the sso plugin than the oidc-provider

<!-- gh-comment-id:3550914167 --> @EnzoAlbornoz commented on GitHub (Nov 19, 2025): Regarding #6053, it doesn't handle the use case I had in mind when I created this issue. This issue is more about the sso plugin than the oidc-provider
Author
Owner

@dosubot[bot] commented on GitHub (Feb 18, 2026):

Hi, @EnzoAlbornoz. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary

  • You requested support for the private_key_jwt client assertion method to enhance OAuth 2.0 client authentication security, particularly for financial-grade APIs like Okta.
  • The maintainers recognize the importance and are considering how to integrate this asymmetric key approach while maintaining backward compatibility.
  • You shared a working prototype implementation in the SSO plugin for Okta.
  • Other users, such as mattss-madetech, have shown interest due to GOV.UK One Login requirements.
  • The ongoing discussion is focused on the SSO plugin rather than the oidc-provider.

Next Steps

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open.
  • If I do not hear back within 7 days, this issue will be automatically closed.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3921724396 --> @dosubot[bot] commented on GitHub (Feb 18, 2026): Hi, @EnzoAlbornoz. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary** - You requested support for the private_key_jwt client assertion method to enhance OAuth 2.0 client authentication security, particularly for financial-grade APIs like Okta. - The maintainers recognize the importance and are considering how to integrate this asymmetric key approach while maintaining backward compatibility. - You shared a working prototype implementation in the SSO plugin for Okta. - Other users, such as mattss-madetech, have shown interest due to GOV.UK One Login requirements. - The ongoing discussion is focused on the SSO plugin rather than the oidc-provider. **Next Steps** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here to keep the discussion open. - If I do not hear back within 7 days, this issue will be automatically closed. Thank you for your understanding and contribution!
Author
Owner

@Bekacru commented on GitHub (Feb 18, 2026):

@Paola3stefania

<!-- gh-comment-id:3923594756 --> @Bekacru commented on GitHub (Feb 18, 2026): @Paola3stefania
Author
Owner

@gustavovalverde commented on GitHub (Mar 31, 2026):

@EnzoAlbornoz @mattss-madetech can you have a look at:

This wasn't a trivial addition, so if you're able to test that branch I'd appreciate it

<!-- gh-comment-id:4159829219 --> @gustavovalverde commented on GitHub (Mar 31, 2026): @EnzoAlbornoz @mattss-madetech can you have a look at: - https://github.com/better-auth/better-auth/pull/8836 This wasn't a trivial addition, so if you're able to test that branch I'd appreciate it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10380