[PR #8214] feat(oauth-provider): public client prelogin endpoint #7825

Open
opened 2026-03-13 13:50:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8214
Author: @dvanmali
Created: 2/28/2026
Status: 🔄 Open

Base: canaryHead: opPublicClient


📝 Commits (3)

📊 Changes

9 files changed (+134 additions, -21 deletions)

View changed files

📝 docs/content/docs/plugins/oauth-provider.mdx (+27 -0)
📝 packages/oauth-provider/src/client.ts (+2 -1)
packages/oauth-provider/src/middleware/index.ts (+17 -0)
📝 packages/oauth-provider/src/oauth.ts (+13 -15)
📝 packages/oauth-provider/src/oauthClient/endpoints.test.ts (+24 -1)
📝 packages/oauth-provider/src/oauthClient/endpoints.ts (+3 -2)
📝 packages/oauth-provider/src/oauthClient/index.ts (+26 -2)
📝 packages/oauth-provider/src/types/index.ts (+5 -0)
📝 packages/oauth-provider/src/utils/index.ts (+17 -0)

📄 Description

Creates a new endpoint for prelogin public client fetching: /oauth2/public-client-prelogin. This endpoint must be enabled in the configuration via allowPublicClientPrelogin. Maintains security via a new middleware that checks for valid oauth_query parameters.

Closes: #8150


Summary by cubic

Adds a pre-login endpoint for public OAuth client info so apps can render login/consent UI before auth. Also removes unused code.

  • New Features

    • POST /oauth2/public-client-prelogin returns public-only client fields before login.
    • Requires allowPublicClientPrelogin: true and a valid oauth_query (sig + exp) verified via middleware using a shared verifyOAuthQueryParams utility.
    • SDK method: authClient.oauth2.publicClientPrelogin; docs and tests added.
  • Migration

    • Enable allowPublicClientPrelogin in oauthProvider config.
    • Call the endpoint with client_id and a signed oauth_query (the SDK handles this automatically).

Written for commit ce7d7a2c8688eb8a2bee362b763641ec5d099825. 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/8214 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 2/28/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `opPublicClient` --- ### 📝 Commits (3) - [`e22dd12`](https://github.com/better-auth/better-auth/commit/e22dd12480da0f6f73a8d771cd6e19a240274cca) feat: prelogin public client fetch - [`13b3357`](https://github.com/better-auth/better-auth/commit/13b3357763392ccdb1a9f2ac24f6dd1709996893) fix: suggestions - [`ce7d7a2`](https://github.com/better-auth/better-auth/commit/ce7d7a2c8688eb8a2bee362b763641ec5d099825) chore: rm unused code ### 📊 Changes **9 files changed** (+134 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/oauth-provider.mdx` (+27 -0) 📝 `packages/oauth-provider/src/client.ts` (+2 -1) ➕ `packages/oauth-provider/src/middleware/index.ts` (+17 -0) 📝 `packages/oauth-provider/src/oauth.ts` (+13 -15) 📝 `packages/oauth-provider/src/oauthClient/endpoints.test.ts` (+24 -1) 📝 `packages/oauth-provider/src/oauthClient/endpoints.ts` (+3 -2) 📝 `packages/oauth-provider/src/oauthClient/index.ts` (+26 -2) 📝 `packages/oauth-provider/src/types/index.ts` (+5 -0) 📝 `packages/oauth-provider/src/utils/index.ts` (+17 -0) </details> ### 📄 Description Creates a new endpoint for prelogin public client fetching: `/oauth2/public-client-prelogin`. This endpoint must be enabled in the configuration via `allowPublicClientPrelogin`. Maintains security via a new middleware that checks for valid `oauth_query` parameters. Closes: #8150 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a pre-login endpoint for public OAuth client info so apps can render login/consent UI before auth. Also removes unused code. - **New Features** - POST /oauth2/public-client-prelogin returns public-only client fields before login. - Requires allowPublicClientPrelogin: true and a valid oauth_query (sig + exp) verified via middleware using a shared verifyOAuthQueryParams utility. - SDK method: authClient.oauth2.publicClientPrelogin; docs and tests added. - **Migration** - Enable allowPublicClientPrelogin in oauthProvider config. - Call the endpoint with client_id and a signed oauth_query (the SDK handles this automatically). <sup>Written for commit ce7d7a2c8688eb8a2bee362b763641ec5d099825. 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:50:19 -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#7825