[PR #6286] [CLOSED] feat(auth): form-based-auth #14816

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6286
Author: @Paola3stefania
Created: 11/25/2025
Status: Closed

Base: canaryHead: feat/form-based-auth


📝 Commits (10+)

📊 Changes

9 files changed (+1975 additions, -197 deletions)

View changed files

📝 docs/content/docs/authentication/email-password.mdx (+138 -0)
📝 packages/better-auth/src/api/index.test.ts (+171 -1)
📝 packages/better-auth/src/api/index.ts (+52 -1)
📝 packages/better-auth/src/api/routes/sign-in.test.ts (+166 -0)
📝 packages/better-auth/src/api/routes/sign-up.test.ts (+148 -0)
packages/better-auth/src/api/utils/parse-form-body.test.ts (+984 -0)
packages/better-auth/src/api/utils/parse-form-body.ts (+120 -0)
📝 packages/better-auth/src/plugins/oidc-provider/oidc.test.ts (+195 -195)
📝 packages/core/src/error/codes.ts (+1 -0)

📄 Description

Summary by cubic

Add native support for HTML form submissions for email sign-in and sign-up. Forms are parsed server-side to JSON with strict content-type checks; the OAuth2 token endpoint accepts form-encoded as-is.

  • New Features

    • Accept application/x-www-form-urlencoded on POST /sign-in/email and /sign-up/email; requests are converted to JSON in onRequest.
    • JSON remains supported; behavior (errors, cookies, origin/CSRF) matches JSON flow.
    • Reject form bodies on other endpoints (except /oauth2/token) and any non-JSON, non-form POST with 400 UNSUPPORTED_CONTENT_TYPE.
    • Added parse-form-body utilities (detection, parsing, conversion, duplicate-field rejection), updated router allowedMediaTypes, and comprehensive tests and docs.
  • Migration

    • No changes for existing JSON clients.
    • To submit forms, send Content-Type: application/x-www-form-urlencoded to the two supported endpoints only; use JSON elsewhere.

Written for commit 8040809db8. Summary will update automatically 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/6286 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 11/25/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/form-based-auth` --- ### 📝 Commits (10+) - [`8da6a54`](https://github.com/better-auth/better-auth/commit/8da6a54c38478e3ae4bca5c37c9a61852438dd21) feat: form proxy - [`e85e02e`](https://github.com/better-auth/better-auth/commit/e85e02edf2a4178138fbb8406507955342a04ab5) Merge branch 'canary' into feat/form-based-auth - [`0d8bf3e`](https://github.com/better-auth/better-auth/commit/0d8bf3e7d0f363130db26b9c17e04adf8cae45f2) feat: docu - [`b77eed1`](https://github.com/better-auth/better-auth/commit/b77eed13fa9954c139cac821241097b760b29103) Merge branch 'feat/form-based-auth' of https://github.com/Paola3stefania/better-auth into feat/form-based-auth - [`4139810`](https://github.com/better-auth/better-auth/commit/413981033d0c160b0df50f92ca756db372dd91f4) fix: doc - [`5f8bfe8`](https://github.com/better-auth/better-auth/commit/5f8bfe8633c255d924e69437244e7f4dee2190cf) fix: lint and unique keys - [`79a1c97`](https://github.com/better-auth/better-auth/commit/79a1c97bd8856cf4f0331e51c045125564b2614f) fix: lint - [`f3d4f52`](https://github.com/better-auth/better-auth/commit/f3d4f52047e70d5314680de41fb44d410cd89d36) fix: test - [`4899bd2`](https://github.com/better-auth/better-auth/commit/4899bd204b4a93765a86df1e3d0bf9ad5b9b907f) fix: validation - [`8040809`](https://github.com/better-auth/better-auth/commit/8040809db8db98ebd401c196d6063e869e46362c) fix: allowed form endpoints ### 📊 Changes **9 files changed** (+1975 additions, -197 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/authentication/email-password.mdx` (+138 -0) 📝 `packages/better-auth/src/api/index.test.ts` (+171 -1) 📝 `packages/better-auth/src/api/index.ts` (+52 -1) 📝 `packages/better-auth/src/api/routes/sign-in.test.ts` (+166 -0) 📝 `packages/better-auth/src/api/routes/sign-up.test.ts` (+148 -0) ➕ `packages/better-auth/src/api/utils/parse-form-body.test.ts` (+984 -0) ➕ `packages/better-auth/src/api/utils/parse-form-body.ts` (+120 -0) 📝 `packages/better-auth/src/plugins/oidc-provider/oidc.test.ts` (+195 -195) 📝 `packages/core/src/error/codes.ts` (+1 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add native support for HTML form submissions for email sign-in and sign-up. Forms are parsed server-side to JSON with strict content-type checks; the OAuth2 token endpoint accepts form-encoded as-is. - **New Features** - Accept application/x-www-form-urlencoded on POST /sign-in/email and /sign-up/email; requests are converted to JSON in onRequest. - JSON remains supported; behavior (errors, cookies, origin/CSRF) matches JSON flow. - Reject form bodies on other endpoints (except /oauth2/token) and any non-JSON, non-form POST with 400 UNSUPPORTED_CONTENT_TYPE. - Added parse-form-body utilities (detection, parsing, conversion, duplicate-field rejection), updated router allowedMediaTypes, and comprehensive tests and docs. - **Migration** - No changes for existing JSON clients. - To submit forms, send Content-Type: application/x-www-form-urlencoded to the two supported endpoints only; use JSON elsewhere. <sup>Written for commit 8040809db8db98ebd401c196d6063e869e46362c. Summary will update automatically 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 09:39: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#14816