[PR #5816] [MERGED] chore: remove additionalData config for oauth config #6246

Closed
opened 2026-03-13 12:52:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5816
Author: @Bekacru
Created: 11/7/2025
Status: Merged
Merged: 11/7/2025
Merged by: @Bekacru

Base: canaryHead: fix/oauthflow


📝 Commits (6)

  • 5aa43e8 chore: remove config
  • 5c660bb add test
  • 4249755 Update packages/better-auth/src/api/middlewares/oauth.ts
  • 8c66517 Update docs/content/docs/concepts/oauth.mdx
  • ee53bc7 Update packages/better-auth/src/oauth2/state.ts
  • 57f382c parse value

📊 Changes

9 files changed (+256 additions, -170 deletions)

View changed files

📝 docs/content/docs/concepts/oauth.mdx (+57 -76)
📝 packages/better-auth/src/api/middlewares/oauth.ts (+18 -29)
📝 packages/better-auth/src/call.test.ts (+5 -11)
📝 packages/better-auth/src/oauth2/state.ts (+23 -24)
📝 packages/better-auth/src/social.test.ts (+140 -0)
📝 packages/better-auth/src/test-utils/test-instance.ts (+1 -1)
📝 packages/core/package.json (+2 -1)
📝 packages/core/src/context/request-state.ts (+10 -5)
📝 packages/core/src/types/init-options.ts (+0 -23)

📄 Description

Summary by cubic

Removed oauthConfig.additionalData and made custom fields part of the OAuth state by default. This simplifies setup, exposes extra data via getOAuthState during the OAuth callback, and prevents overriding core state fields.

  • Refactors

    • Dropped advanced.oauthConfig.additionalData and its schema validation.
    • OAuth state now includes default fields plus any custom keys; core fields cannot be overridden.
    • Renamed setOauthState to setOAuthState; exported getOAuthState unchanged.
    • generateState merges additionalData into state and stores it; parseState accepts loose fields.
    • defineRequestState now has a default permissive schema.
    • Updated docs, tests, and types accordingly.
  • Migration

    • Remove advanced.oauthConfig.additionalData from your config.
    • Replace setOauthState with setOAuthState.
    • Move any previous additionalData schema checks to your hooks (e.g., validate with zod).
    • Expect base OAuth state fields (callbackURL, codeVerifier, errorURL, newUserURL, link, requestSignUp, expiresAt) in getOAuthState results.

Written for commit 57f382c3ff. 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/5816 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 11/7/2025 **Status:** ✅ Merged **Merged:** 11/7/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/oauthflow` --- ### 📝 Commits (6) - [`5aa43e8`](https://github.com/better-auth/better-auth/commit/5aa43e89ef755b4cd0247403d4c410823e645dfe) chore: remove config - [`5c660bb`](https://github.com/better-auth/better-auth/commit/5c660bb57dac6f1a10b02bdcae1bf8ba977142fc) add test - [`4249755`](https://github.com/better-auth/better-auth/commit/42497551953f488bf7870e2f8199b6278aa76a97) Update packages/better-auth/src/api/middlewares/oauth.ts - [`8c66517`](https://github.com/better-auth/better-auth/commit/8c66517fb742a76aea0d147180efd97bb060fb3f) Update docs/content/docs/concepts/oauth.mdx - [`ee53bc7`](https://github.com/better-auth/better-auth/commit/ee53bc77df65eb1a0f189ea2fb8187c9ceb27597) Update packages/better-auth/src/oauth2/state.ts - [`57f382c`](https://github.com/better-auth/better-auth/commit/57f382c3ff4d4444f5761e3b45127fb864b33107) parse value ### 📊 Changes **9 files changed** (+256 additions, -170 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/oauth.mdx` (+57 -76) 📝 `packages/better-auth/src/api/middlewares/oauth.ts` (+18 -29) 📝 `packages/better-auth/src/call.test.ts` (+5 -11) 📝 `packages/better-auth/src/oauth2/state.ts` (+23 -24) 📝 `packages/better-auth/src/social.test.ts` (+140 -0) 📝 `packages/better-auth/src/test-utils/test-instance.ts` (+1 -1) 📝 `packages/core/package.json` (+2 -1) 📝 `packages/core/src/context/request-state.ts` (+10 -5) 📝 `packages/core/src/types/init-options.ts` (+0 -23) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Removed oauthConfig.additionalData and made custom fields part of the OAuth state by default. This simplifies setup, exposes extra data via getOAuthState during the OAuth callback, and prevents overriding core state fields. - **Refactors** - Dropped advanced.oauthConfig.additionalData and its schema validation. - OAuth state now includes default fields plus any custom keys; core fields cannot be overridden. - Renamed setOauthState to setOAuthState; exported getOAuthState unchanged. - generateState merges additionalData into state and stores it; parseState accepts loose fields. - defineRequestState now has a default permissive schema. - Updated docs, tests, and types accordingly. - **Migration** - Remove advanced.oauthConfig.additionalData from your config. - Replace setOauthState with setOAuthState. - Move any previous additionalData schema checks to your hooks (e.g., validate with zod). - Expect base OAuth state fields (callbackURL, codeVerifier, errorURL, newUserURL, link, requestSignUp, expiresAt) in getOAuthState results. <sup>Written for commit 57f382c3ff4d4444f5761e3b45127fb864b33107. 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-03-13 12:52:18 -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#6246