[PR #4974] [MERGED] fix(oidc): properly enforce consent requirements per OIDC spec #13935

Closed
opened 2026-04-13 09:13:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4974
Author: @himself65
Created: 9/30/2025
Status: Merged
Merged: 9/30/2025
Merged by: @himself65

Base: canaryHead: himself65/2025/09/29/consent-flow


📝 Commits (10+)

📊 Changes

3 files changed (+190 additions, -79 deletions)

View changed files

📝 packages/better-auth/src/plugins/oidc-provider/authorize.ts (+42 -42)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+3 -2)
📝 packages/better-auth/src/plugins/oidc-provider/oidc.test.ts (+145 -35)

📄 Description

Summary by cubic

Enforces OIDC consent correctly: consent is required unless the client is trusted or the user previously consented, and prompt=consent always forces consent. Authorization now decides when to show consent and only redirects with a code when consent isn’t needed.

  • Bug Fixes
    • Authorization computes requireConsent: !skipConsent && (!hasAlreadyConsented || prompt==="consent").
    • Removes forced prompt="consent" in cookie-based flow; lets authorize decide per spec.
    • Redirects with code immediately when consent isn’t required; otherwise routes to consent page/cookie flow with state preserved.
    • Updates consent endpoint schema to accept nullish consent_code for cookie-based flows.
    • Expands tests with a consent-flow helper and coverage for trusted vs. untrusted clients and JWT signing paths.

🔄 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/4974 **Author:** [@himself65](https://github.com/himself65) **Created:** 9/30/2025 **Status:** ✅ Merged **Merged:** 9/30/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2025/09/29/consent-flow` --- ### 📝 Commits (10+) - [`825f8e1`](https://github.com/better-auth/better-auth/commit/825f8e1d7ca9eba91e8b80acce491684c9437692) init - [`b2ddc0c`](https://github.com/better-auth/better-auth/commit/b2ddc0c1b484ecf555d7f7a30c9d3e72313eb962) blog - [`22cd9f0`](https://github.com/better-auth/better-auth/commit/22cd9f0c95626a0c525753e4e51d2d53e115464e) chore: dotenv - [`42af8f8`](https://github.com/better-auth/better-auth/commit/42af8f81d13d1ea808928b1d714a1606d5666fe9) update - [`7af508e`](https://github.com/better-auth/better-auth/commit/7af508ee908f764ee9458f6bc9eeb6ab4c825d6d) some update - [`1be889b`](https://github.com/better-auth/better-auth/commit/1be889bb831c879474bdc51cdf96264a13b666a5) docs: add mentions - [`8bc6b18`](https://github.com/better-auth/better-auth/commit/8bc6b18c702b70c9919d27840420e50bd6c61d5e) updates - [`8aeb9b0`](https://github.com/better-auth/better-auth/commit/8aeb9b018835ff93cec8ed6eb837a0a3523ea2aa) chore: use tsconfig monorepo setup (#4826) - [`a3baacb`](https://github.com/better-auth/better-auth/commit/a3baacb148ee8120a19641f6442f993037354f20) docs: change banner - [`d007bda`](https://github.com/better-auth/better-auth/commit/d007bdac99ad626ec8233b32eeedd5bb3de036cb) docs: add link to auth.js team announcement ### 📊 Changes **3 files changed** (+190 additions, -79 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oidc-provider/authorize.ts` (+42 -42) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+3 -2) 📝 `packages/better-auth/src/plugins/oidc-provider/oidc.test.ts` (+145 -35) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Enforces OIDC consent correctly: consent is required unless the client is trusted or the user previously consented, and prompt=consent always forces consent. Authorization now decides when to show consent and only redirects with a code when consent isn’t needed. - **Bug Fixes** - Authorization computes requireConsent: !skipConsent && (!hasAlreadyConsented || prompt==="consent"). - Removes forced prompt="consent" in cookie-based flow; lets authorize decide per spec. - Redirects with code immediately when consent isn’t required; otherwise routes to consent page/cookie flow with state preserved. - Updates consent endpoint schema to accept nullish consent_code for cookie-based flows. - Expands tests with a consent-flow helper and coverage for trusted vs. untrusted clients and JWT signing paths. <!-- 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-13 09:13:27 -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#13935