[PR #5401] [MERGED] fix(mcp): consent requirement should be respected #31583

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5401
Author: @okisdev
Created: 10/18/2025
Status: Merged
Merged: 10/20/2025
Merged by: @Bekacru

Base: canaryHead: fix(mcp)/error-bypass-consent


📝 Commits (1)

  • 273bbe3 fix(mcp): error bypass consent

📊 Changes

3 files changed (+177 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/plugins/mcp/authorize.ts (+27 -6)
📝 packages/better-auth/src/plugins/mcp/index.ts (+1 -0)
📝 packages/better-auth/src/plugins/mcp/mcp.test.ts (+149 -0)

📄 Description

This PR fixed #4736 to avoid the consent bypassing.

  • fix consent handling logic
  • expose consent endpoint
  • adding more test cases based on user feedback

Summary by cubic

Fixes an OAuth consent bypass in MCP by enforcing the prompt=consent flow and exposing a consent endpoint. Non-consent flows still redirect directly with an authorization code.

  • Bug Fixes

    • Enforce prompt=consent: set a signed consent cookie, redirect to the configured consentPage with a consent_code, and only issue the code after consent; otherwise, redirect directly with the code.
    • Added tests covering both consent and non-consent flows.
  • New Features

    • Exposed the OAuth consent endpoint to handle consent acceptance and final redirect.

🔄 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/5401 **Author:** [@okisdev](https://github.com/okisdev) **Created:** 10/18/2025 **Status:** ✅ Merged **Merged:** 10/20/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix(mcp)/error-bypass-consent` --- ### 📝 Commits (1) - [`273bbe3`](https://github.com/better-auth/better-auth/commit/273bbe3771e42e81aa75745b184d616325a54914) fix(mcp): error bypass consent ### 📊 Changes **3 files changed** (+177 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/mcp/authorize.ts` (+27 -6) 📝 `packages/better-auth/src/plugins/mcp/index.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/mcp/mcp.test.ts` (+149 -0) </details> ### 📄 Description This PR fixed #4736 to avoid the consent bypassing. - fix `consent` handling logic - expose consent endpoint - adding more test cases based on user feedback <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes an OAuth consent bypass in MCP by enforcing the prompt=consent flow and exposing a consent endpoint. Non-consent flows still redirect directly with an authorization code. - **Bug Fixes** - Enforce prompt=consent: set a signed consent cookie, redirect to the configured consentPage with a consent_code, and only issue the code after consent; otherwise, redirect directly with the code. - Added tests covering both consent and non-consent flows. - **New Features** - Exposed the OAuth consent endpoint to handle consent acceptance and final redirect. <!-- 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:28:51 -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#31583