[PR #9123] [MERGED] fix(oauth-provider): graceful DCR override for unauthenticated confidential clients #25355

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/9123
Author: @gustavovalverde
Created: 4/11/2026
Status: Merged
Merged: 4/11/2026
Merged by: @gustavovalverde

Base: mainHead: fix/dcr-graceful-override-confidential


📝 Commits (4)

  • 7aafffb fix(oauth-provider): override confidential auth methods to public in unauthenticated DCR
  • 866c24b fix(oauth-provider): harden unauthenticated DCR override and add e2e test
  • 1a01c52 fix(oauth-provider): address review feedback on JSDoc and type assertion
  • 9a7fc03 chore: trim changeset to rationale only

📊 Changes

3 files changed (+265 additions, -21 deletions)

View changed files

.changeset/dcr-graceful-override-confidential.md (+7 -0)
📝 packages/oauth-provider/src/register.test.ts (+221 -3)
📝 packages/oauth-provider/src/register.ts (+37 -18)

📄 Description

Summary

When allowUnauthenticatedClientRegistration is enabled, unauthenticated DCR requests that specify client_secret_post, client_secret_basic, or omit token_endpoint_auth_method entirely are now overridden to "none" (public client) instead of being rejected with HTTP 401.

RFC 7591 Section 3.2.1 explicitly allows this: the server MAY replace requested metadata values with suitable values. The registration response communicates the actual method back so compliant clients can adjust.

Closes #8588

What changed

  • Override confidential auth methods to "none" for unauthenticated DCR via a pure resolveUnauthenticatedAuth resolver (no direct body mutation)
  • Reject client_credentials grant in unauthenticated DCR; public clients have no secret, so the grant would always fail at the token endpoint
  • Clear type: "web" during override since it is only valid for confidential clients
  • End-to-end test: unauthenticated DCR with client_secret_post -> authorize -> PKCE token exchange

🔄 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/9123 **Author:** [@gustavovalverde](https://github.com/gustavovalverde) **Created:** 4/11/2026 **Status:** ✅ Merged **Merged:** 4/11/2026 **Merged by:** [@gustavovalverde](https://github.com/gustavovalverde) **Base:** `main` ← **Head:** `fix/dcr-graceful-override-confidential` --- ### 📝 Commits (4) - [`7aafffb`](https://github.com/better-auth/better-auth/commit/7aafffb901340b0d8c400fce5db94a4810adc8a7) fix(oauth-provider): override confidential auth methods to public in unauthenticated DCR - [`866c24b`](https://github.com/better-auth/better-auth/commit/866c24b5390205419b3950957d30b1f3bfa43e8d) fix(oauth-provider): harden unauthenticated DCR override and add e2e test - [`1a01c52`](https://github.com/better-auth/better-auth/commit/1a01c52ecc84a1a81e4a02e6c5207254e0a16319) fix(oauth-provider): address review feedback on JSDoc and type assertion - [`9a7fc03`](https://github.com/better-auth/better-auth/commit/9a7fc035e085745291b9eaab8be9c2a81c1e294c) chore: trim changeset to rationale only ### 📊 Changes **3 files changed** (+265 additions, -21 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/dcr-graceful-override-confidential.md` (+7 -0) 📝 `packages/oauth-provider/src/register.test.ts` (+221 -3) 📝 `packages/oauth-provider/src/register.ts` (+37 -18) </details> ### 📄 Description ## Summary When `allowUnauthenticatedClientRegistration` is enabled, unauthenticated DCR requests that specify `client_secret_post`, `client_secret_basic`, or omit `token_endpoint_auth_method` entirely are now overridden to `"none"` (public client) instead of being rejected with HTTP 401. [RFC 7591 Section 3.2.1](https://datatracker.ietf.org/doc/html/rfc7591#section-3.2.1) explicitly allows this: the server MAY replace requested metadata values with suitable values. The registration response communicates the actual method back so compliant clients can adjust. Closes #8588 ## What changed - Override confidential auth methods to `"none"` for unauthenticated DCR via a pure `resolveUnauthenticatedAuth` resolver (no direct body mutation) - Reject `client_credentials` grant in unauthenticated DCR; public clients have no secret, so the grant would always fail at the token endpoint - Clear `type: "web"` during override since it is only valid for confidential clients - End-to-end test: unauthenticated DCR with `client_secret_post` -> authorize -> PKCE token exchange --- <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-15 22:51:06 -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#25355