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

Closed
opened 2026-04-13 10:22:28 -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: Merged
Merged: 3/18/2026
Merged by: @himself65

Base: canaryHead: opPublicClient


📝 Commits (3)

📊 Changes

8 files changed (+131 additions, -20 deletions)

View changed files

📝 docs/content/docs/plugins/oauth-provider.mdx (+27 -0)
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 (+16 -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 centralizes signature verification and 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 by 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 4361ea9412. 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:** ✅ Merged **Merged:** 3/18/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `opPublicClient` --- ### 📝 Commits (3) - [`28f6494`](https://github.com/better-auth/better-auth/commit/28f6494008ec2ecb9a6dee69d406d7ac6aba39dd) feat: prelogin public client fetch - [`2ff886d`](https://github.com/better-auth/better-auth/commit/2ff886d340327c14baeb08e6342e7eedbf4b04ac) fix: suggestions - [`4361ea9`](https://github.com/better-auth/better-auth/commit/4361ea94122ce4796123abfa209a5f82e3aaa7fb) chore: rm unused code ### 📊 Changes **8 files changed** (+131 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/oauth-provider.mdx` (+27 -0) ➕ `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` (+16 -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 centralizes signature verification and 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 by 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 4361ea94122ce4796123abfa209a5f82e3aaa7fb. 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-04-13 10:22:28 -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#16071