Skip to content

Preserve native Better Auth request body formats - #1042

Merged
jimhoyd merged 1 commit into
mainfrom
codex/auth-native-body-formats
Sep 30, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
codex/auth-native-body-formats

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem and change

The Better Auth mount rejected form-encoded sign-in and operator-enabled plugin formats before the upstream handler could accept them. Forward the original bytes and media type, leaving endpoint format admission to Better Auth.

Keep the universal byte/header bounds and the existing JSON structural and Unicode guard (also for structured-suffix JSON). Validate raw text/form UTF-8 and percent-encoded form bytes without interpreting fields or changing duplicate-field semantics. Update the auth contract and the extension helper guidance, which previously imposed JSON on every provider body.

Closes #1039. Follows #841; does not resume #837 or add a framework-specific core adapter.

Verification

  • Auth workspace verification: typecheck, build, all 25 tests passed on Node v26.10.0/macOS.
  • New direct-upstream versus mounted conformance covers JSON and form sign-in, a plugin declaring plain text and structured-suffix JSON, upstream media-type refusal, foreign-origin refusal, and disabled paths.
  • Malformed JSON Unicode, raw/percent-encoded invalid UTF-8 and oversized forms are refused without a session cookie.
  • Full npm run verify: passed, including lint/typechecks/docs, 1,325 core tests, every workspace suite, packed-addon audits/integration, both provider proofs, ecosystem integration and multiprocess tests (1,736 tests total, zero failures).

Compatibility and security

No YAML fields, dependency changes, schema migrations or sandbox changes. The original path allowlist, upstream CSRF/origin checks, rate limits, storage-failure handling and credential projection remain in place. For unsupported formats the upstream error envelope is now preserved. Binary/multipart parsing belongs to the enabled upstream endpoint; this does not promise every Better Auth plugin is supported or apply JSON-specific structural guards to binary payloads. No external OAuth provider was contacted.

  • Changes match the documented portable contract; docs/examples are updated where needed.
  • Relevant tests and package checks pass, or limitations are explained above.
  • No credentials, customer data or private project material are included.
  • Runtime/starter changes remain aligned where applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Preserve upstream body formats through the Better Auth adapter

1 participant