[PR #7007] [MERGED] chore(better-auth): fix inferred trusted origins on cloned context #32619

Closed
opened 2026-04-17 23:23:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7007
Author: @jonathansamines
Created: 12/26/2025
Status: Merged
Merged: 12/27/2025
Merged by: @Bekacru

Base: canaryHead: chore/fix-inferred-trusted-origins-checks


📝 Commits (5)

  • 6ed18fe chore(better-auth): update inferred trusted origin tests
  • b2ebebc chore(better-auth): add failing test case
  • 2ad3b62 chore(better-auth): fix trusted origins when context is clonned
  • 16e67c7 chore(better-auth): remove .only modifier
  • 3e828d7 chore(sso): avoid context dereferencing for isTrustedOrigin util

📊 Changes

4 files changed (+46 additions, -3 deletions)

View changed files

📝 packages/better-auth/src/api/middlewares/origin-check.test.ts (+5 -0)
📝 packages/better-auth/src/auth/trusted-origins.test.ts (+39 -1)
📝 packages/better-auth/src/context/create-context.ts (+1 -1)
📝 packages/sso/src/routes/sso.ts (+1 -1)

📄 Description

Closes #6798

Summary by cubic

Fixes trusted-origin checks when baseURL is inferred so the app’s origin is always allowed, even if the auth context is cloned or updated. Strengthens tests to ensure untrusted origins are still rejected.

  • Bug Fixes
    • Use this.trustedOrigins in origin matching to avoid stale context after cloning/updates.
    • Set baseURL: undefined in tests and add cases that allow the inferred app origin (including paths) and reject non-trusted origins.

Written for commit 3e828d7ee6. 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/7007 **Author:** [@jonathansamines](https://github.com/jonathansamines) **Created:** 12/26/2025 **Status:** ✅ Merged **Merged:** 12/27/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `chore/fix-inferred-trusted-origins-checks` --- ### 📝 Commits (5) - [`6ed18fe`](https://github.com/better-auth/better-auth/commit/6ed18fea5ffb60896dac08b6a110d9139c08bd06) chore(better-auth): update inferred trusted origin tests - [`b2ebebc`](https://github.com/better-auth/better-auth/commit/b2ebebc883b510c38078653587da0b5d47cd880d) chore(better-auth): add failing test case - [`2ad3b62`](https://github.com/better-auth/better-auth/commit/2ad3b62e771b950d78c94d4d4ecfebedd81fa3f1) chore(better-auth): fix trusted origins when context is clonned - [`16e67c7`](https://github.com/better-auth/better-auth/commit/16e67c75f42f908d869bc61e081ca924b78eab68) chore(better-auth): remove .only modifier - [`3e828d7`](https://github.com/better-auth/better-auth/commit/3e828d7ee69aa6a958a933c49854e17149b09522) chore(sso): avoid context dereferencing for isTrustedOrigin util ### 📊 Changes **4 files changed** (+46 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/middlewares/origin-check.test.ts` (+5 -0) 📝 `packages/better-auth/src/auth/trusted-origins.test.ts` (+39 -1) 📝 `packages/better-auth/src/context/create-context.ts` (+1 -1) 📝 `packages/sso/src/routes/sso.ts` (+1 -1) </details> ### 📄 Description Closes #6798 <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes trusted-origin checks when baseURL is inferred so the app’s origin is always allowed, even if the auth context is cloned or updated. Strengthens tests to ensure untrusted origins are still rejected. - **Bug Fixes** - Use this.trustedOrigins in origin matching to avoid stale context after cloning/updates. - Set baseURL: undefined in tests and add cases that allow the inferred app origin (including paths) and reject non-trusted origins. <sup>Written for commit 3e828d7ee69aa6a958a933c49854e17149b09522. 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-17 23:23:09 -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#32619