[PR #7745] [MERGED] fix(bearer): support case-insensitive scheme and handle token URL encoding #7530

Closed
opened 2026-03-13 13:40:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7745
Author: @bytaesu
Created: 2/1/2026
Status: Merged
Merged: 2/28/2026
Merged by: @Bekacru

Base: canaryHead: 2026-02-01/fix/bearer-case-and-encoding


📝 Commits (3)

  • 9accda6 fix(bearer): support case-insensitive scheme and handle token URL encoding
  • 70074c2 Merge branch 'canary' into 2026-02-01/fix/bearer-case-and-encoding
  • a6c29c1 test: clearer naming

📊 Changes

2 files changed (+58 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/bearer/bearer.test.ts (+27 -0)
📝 packages/better-auth/src/plugins/bearer/index.ts (+31 -6)

📄 Description

Note

This PR makes the Bearer plugin more flexible in handling scheme casing and encoding.
https://datatracker.ietf.org/doc/html/rfc7235#section-2.1


Summary by cubic

Make the Bearer auth plugin accept a case-insensitive scheme and correctly handle URL-encoded tokens to prevent rejected sessions from mixed casing or encoding. Closes better-auth/better-auth#6583.

  • Bug Fixes
    • Accept "Bearer" in any case and ignore extra whitespace (RFC 7235).
    • Support URL-encoded and decoded tokens; encode JWT-style tokens when needed and safely decode before HMAC verification.
    • Add tests for scheme casing and token encoding.

Written for commit a6c29c1d6e. 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/7745 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/1/2026 **Status:** ✅ Merged **Merged:** 2/28/2026 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `2026-02-01/fix/bearer-case-and-encoding` --- ### 📝 Commits (3) - [`9accda6`](https://github.com/better-auth/better-auth/commit/9accda65e7cd00545ad765611c6598d5044b56c1) fix(bearer): support case-insensitive scheme and handle token URL encoding - [`70074c2`](https://github.com/better-auth/better-auth/commit/70074c23bf836657e41339ac70828ee1bc6a5c88) Merge branch 'canary' into 2026-02-01/fix/bearer-case-and-encoding - [`a6c29c1`](https://github.com/better-auth/better-auth/commit/a6c29c1d6ef9ce4ac524cd66ca4c84de79066081) test: clearer naming ### 📊 Changes **2 files changed** (+58 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/bearer/bearer.test.ts` (+27 -0) 📝 `packages/better-auth/src/plugins/bearer/index.ts` (+31 -6) </details> ### 📄 Description > [!NOTE] > This PR makes the Bearer plugin more flexible in handling scheme casing and encoding. > https://datatracker.ietf.org/doc/html/rfc7235#section-2.1 - Closes https://github.com/better-auth/better-auth/issues/6583 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make the Bearer auth plugin accept a case-insensitive scheme and correctly handle URL-encoded tokens to prevent rejected sessions from mixed casing or encoding. Closes better-auth/better-auth#6583. - **Bug Fixes** - Accept "Bearer" in any case and ignore extra whitespace (RFC 7235). - Support URL-encoded and decoded tokens; encode JWT-style tokens when needed and safely decode before HMAC verification. - Add tests for scheme casing and token encoding. <sup>Written for commit a6c29c1d6ef9ce4ac524cd66ca4c84de79066081. 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-03-13 13:40: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#7530