[PR #4072] [MERGED] feat: add disableSettingJwtHeader flag to prevent issuance of signed jwt #30768

Closed
opened 2026-04-17 21:47:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4072
Author: @dvanmali
Created: 8/18/2025
Status: Merged
Merged: 8/18/2025
Merged by: @Bekacru

Base: canaryHead: disableSettingJwtHeader


📝 Commits (1)

  • aa4cdc5 feat: add disableSettingJwtHeader flag to prevent issuance of signed jwt

📊 Changes

3 files changed (+36 additions, -1 deletions)

View changed files

📝 docs/content/docs/plugins/jwt.mdx (+15 -0)
📝 docs/content/docs/plugins/oidc-provider.mdx (+6 -1)
📝 packages/better-auth/src/plugins/jwt/index.ts (+15 -0)

📄 Description

Added disableSettingJwtHeader to disable setting jwt in header.

For oAuth compliance, tokens should be signed based on scope permissions. Disabling the header for oAuth means user tokens would not be signed without permission checks. Scope checks should be performed at /oauth2/userinfo. Additionally the /token endpoint should be disabled for the same reason and utilize its equivalent /oauth2/token.

Partial https://github.com/better-auth/better-auth/pull/3572

Type: PATCH


Summary by cubic

Adds disableSettingJwtHeader to the JWT plugin to stop the middleware from setting a signed JWT in response headers. This enables OAuth/OIDC-compliant flows where scope checks happen at /oauth2/userinfo.

  • New Features

    • jwt({ disableSettingJwtHeader: true }) prevents setting the JWT header via middleware.
    • Recommended when using OAuth provider plugins (OIDC, MCP).
  • Migration

    • If acting as an OAuth provider, enable disableSettingJwtHeader.
    • Disable /token (use /oauth2/token) and perform scope checks at /oauth2/userinfo.

🔄 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/4072 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 8/18/2025 **Status:** ✅ Merged **Merged:** 8/18/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `disableSettingJwtHeader` --- ### 📝 Commits (1) - [`aa4cdc5`](https://github.com/better-auth/better-auth/commit/aa4cdc5cdd86fd5cc0ceb05b5297555d7f8f0455) feat: add disableSettingJwtHeader flag to prevent issuance of signed jwt ### 📊 Changes **3 files changed** (+36 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/jwt.mdx` (+15 -0) 📝 `docs/content/docs/plugins/oidc-provider.mdx` (+6 -1) 📝 `packages/better-auth/src/plugins/jwt/index.ts` (+15 -0) </details> ### 📄 Description Added `disableSettingJwtHeader` to disable setting jwt in header. For oAuth compliance, tokens should be signed based on scope permissions. Disabling the header for oAuth means user tokens would not be signed without permission checks. Scope checks should be performed at `/oauth2/userinfo`. Additionally the `/token` endpoint should be disabled for the same reason and utilize its equivalent `/oauth2/token`. Partial https://github.com/better-auth/better-auth/pull/3572 Type: **PATCH** <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds disableSettingJwtHeader to the JWT plugin to stop the middleware from setting a signed JWT in response headers. This enables OAuth/OIDC-compliant flows where scope checks happen at /oauth2/userinfo. - **New Features** - jwt({ disableSettingJwtHeader: true }) prevents setting the JWT header via middleware. - Recommended when using OAuth provider plugins (OIDC, MCP). - **Migration** - If acting as an OAuth provider, enable disableSettingJwtHeader. - Disable /token (use /oauth2/token) and perform scope checks at /oauth2/userinfo. <!-- 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 21:47:48 -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#30768