[PR #3572] feat(jwt): remote jwks, remote signing, and exportable signJwt function #4890

Open
opened 2026-03-13 12:03:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3572
Author: @dvanmali
Created: 7/23/2025
Status: 🔄 Open

Base: canaryHead: jwt-main


📝 Commits (10+)

  • 1efaf7b feat: remote jwks, remote signing, and exportable signJwt function
  • 51bf07e style: change disallow to allow for readability
  • 23e0cf7 fix: make clear the exportable functions of plugin
  • c7dd460 feat: add iat to consolidate start time
  • e09a483 fix: iat and exp should be in seconds but not reflected
  • 84558a4 fix: suggestions from LightTab2
  • f6bdf9e fix: remove allowFutureIatTime flag, iat shall always be current or in the past, and iat is optional
  • e54c993 fix: remote plugin checking
  • cf90f79 fix: cubic-dev-ai suggestions
  • 4744265 chore: move back into return statement to enable plugin users to prevent client import warning

📊 Changes

10 files changed (+868 additions, -528 deletions)

View changed files

📝 docs/content/docs/plugins/jwt.mdx (+101 -0)
📝 docs/content/docs/plugins/oidc-provider.mdx (+9 -4)
📝 packages/better-auth/src/plugins/jwt/index.ts (+62 -185)
📝 packages/better-auth/src/plugins/jwt/jwt.test.ts (+221 -176)
📝 packages/better-auth/src/plugins/jwt/sign.ts (+201 -40)
packages/better-auth/src/plugins/jwt/types.ts (+156 -0)
📝 packages/better-auth/src/plugins/jwt/utils.ts (+72 -69)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+29 -54)
📝 packages/better-auth/src/plugins/oidc-provider/oidc.test.ts (+16 -0)
📝 packages/better-auth/src/types/helper.ts (+1 -0)

📄 Description

Features

feat: remoteUrl option disables jwks endpoint and uses this endpoint in oAuth metadata

feat: remote sign payloads using a server-side privateKey environment variable or remote signing service like Google KMS, AWS KMS, Azure Key Vault, etc.

feat: signJwt (previously getJwtToken) now accepts payload as a parameter. Those who utilized exported getJwtToken should utilize signJwt and its payload parameter instead of through options. getJwtToken marked deprecated. signJwt now has safeguards that is enabled by default and can be disabled per plugin implementation.

feat: Added disableSettingJwtHeader to disable setting jwt in header. Useful for oAuth compliance.

feat: exports getJwtPlugin for other plugins

chore: combine shared createJwks functionality

Duplicate #3464
Partial #3458

Breaking Changes

MINOR

  • style: JwtOptions renamed to JwtPluginOptions to match other plugin syntax.
  • fix: getJwtToken deprecated, prefer signJwt instead

🔄 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/3572 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 7/23/2025 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `jwt-main` --- ### 📝 Commits (10+) - [`1efaf7b`](https://github.com/better-auth/better-auth/commit/1efaf7b761056dd30251c691abe7d040d8866415) feat: remote jwks, remote signing, and exportable signJwt function - [`51bf07e`](https://github.com/better-auth/better-auth/commit/51bf07e643fa4a67c9e8445ecc4f020daf24b0dd) style: change disallow to allow for readability - [`23e0cf7`](https://github.com/better-auth/better-auth/commit/23e0cf7a522d80fe2732358dbd99d1f7f0aa5157) fix: make clear the exportable functions of plugin - [`c7dd460`](https://github.com/better-auth/better-auth/commit/c7dd46024cb5042d47b941f92210c71f2dda844f) feat: add iat to consolidate start time - [`e09a483`](https://github.com/better-auth/better-auth/commit/e09a483634708fe386c5417268f5579c51011196) fix: iat and exp should be in seconds but not reflected - [`84558a4`](https://github.com/better-auth/better-auth/commit/84558a45204339f23879611c67a8313d251575d7) fix: suggestions from LightTab2 - [`f6bdf9e`](https://github.com/better-auth/better-auth/commit/f6bdf9e7e880d71529839aa8a182197b8bb089c2) fix: remove allowFutureIatTime flag, iat shall always be current or in the past, and iat is optional - [`e54c993`](https://github.com/better-auth/better-auth/commit/e54c99304034499e851aca3e82e450eea2060597) fix: remote plugin checking - [`cf90f79`](https://github.com/better-auth/better-auth/commit/cf90f790b28bac9e782b64b8d5574d854f4250ae) fix: cubic-dev-ai suggestions - [`4744265`](https://github.com/better-auth/better-auth/commit/4744265656db961aa0833425b1b09ba14d3dab0a) chore: move back into return statement to enable plugin users to prevent client import warning ### 📊 Changes **10 files changed** (+868 additions, -528 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/jwt.mdx` (+101 -0) 📝 `docs/content/docs/plugins/oidc-provider.mdx` (+9 -4) 📝 `packages/better-auth/src/plugins/jwt/index.ts` (+62 -185) 📝 `packages/better-auth/src/plugins/jwt/jwt.test.ts` (+221 -176) 📝 `packages/better-auth/src/plugins/jwt/sign.ts` (+201 -40) ➕ `packages/better-auth/src/plugins/jwt/types.ts` (+156 -0) 📝 `packages/better-auth/src/plugins/jwt/utils.ts` (+72 -69) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+29 -54) 📝 `packages/better-auth/src/plugins/oidc-provider/oidc.test.ts` (+16 -0) 📝 `packages/better-auth/src/types/helper.ts` (+1 -0) </details> ### 📄 Description ## Features **feat**: `remoteUrl` option disables jwks endpoint and uses this endpoint in oAuth metadata **feat**: remote `sign` payloads using a server-side privateKey environment variable or remote signing service like Google KMS, AWS KMS, Azure Key Vault, etc. **feat**: `signJwt` (previously `getJwtToken`) now accepts payload as a parameter. Those who utilized exported `getJwtToken` should utilize `signJwt` and its payload parameter instead of through options. `getJwtToken` marked deprecated. `signJwt` now has safeguards that is enabled by default and can be disabled per plugin implementation. **feat**: Added `disableSettingJwtHeader` to disable setting jwt in header. Useful for oAuth compliance. **feat**: exports `getJwtPlugin` for other plugins **chore**: combine shared createJwks functionality __Duplicate #3464__ __Partial #3458__ ## Breaking Changes **MINOR** - style: `JwtOptions` renamed to `JwtPluginOptions` to match other plugin syntax. - fix: `getJwtToken` deprecated, prefer `signJwt` instead --- <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-03-13 12:03:12 -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#4890