[PR #6551] [MERGED] fix(saml): enforce trusted provider check #23641

Closed
opened 2026-04-15 21:53:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6551
Author: @Paola3stefania
Created: 12/5/2025
Status: Merged
Merged: 12/5/2025
Merged by: @Bekacru

Base: canaryHead: fix/trust-check-SSO-SAML


📝 Commits (7)

📊 Changes

2 files changed (+194 additions, -13 deletions)

View changed files

📝 packages/sso/src/routes/sso.ts (+29 -13)
📝 packages/sso/src/saml.test.ts (+165 -0)

📄 Description


Summary by cubic

Fixes SAML callback trust checks to prevent auto-linking accounts unless the provider is trusted or the domain is verified. This blocks unintended links and redirects with error=account_not_linked when trust is missing.

  • Bug Fixes
    • For existing users, only create an account link if the provider is in trustedProviders or domainVerified and the email domain matches; otherwise redirect with error=account_not_linked.
    • Removed unconditional account linking on callback; now respects accountLinking trust rules.
    • Added tests covering deny (untrusted provider, unverified domain) and allow (trusted provider) scenarios.

Written for commit ce4e81154a. Summary will update automatically on new commits.

This fixes https://github.com/better-auth/better-auth/issues/6481


🔄 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/6551 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 12/5/2025 **Status:** ✅ Merged **Merged:** 12/5/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/trust-check-SSO-SAML` --- ### 📝 Commits (7) - [`c1faa8c`](https://github.com/better-auth/better-auth/commit/c1faa8c18d7b76b34cf4ba055725f6061d2579b6) fix: callback ssosaml trust check - [`08368c2`](https://github.com/better-auth/better-auth/commit/08368c223b0c5def4d9a7f77881c86f459f1e0f3) Merge branch 'canary' into fix/trust-check-SSO-SAML - [`0b3602f`](https://github.com/better-auth/better-auth/commit/0b3602f81a1d4d6586c33b92621c81c2c132acc7) fix: saml test - [`f9fdfff`](https://github.com/better-auth/better-auth/commit/f9fdfff8c04f2bf153e156ebeef81ab949dc6a77) Merge branch 'fix/trust-check-SSO-SAML' of https://github.com/Paola3stefania/better-auth into fix/trust-check-SSO-SAML - [`c39b490`](https://github.com/better-auth/better-auth/commit/c39b4908ba7513af727a20ac7411ea9d19723d3f) fix tests - [`dcf9681`](https://github.com/better-auth/better-auth/commit/dcf9681ab682dcd19edf088b3b4ee85264fd6c36) make lint happy - [`ce4e811`](https://github.com/better-auth/better-auth/commit/ce4e81154a2b71497d879cfc1833f12fc9eddcec) clean up ### 📊 Changes **2 files changed** (+194 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `packages/sso/src/routes/sso.ts` (+29 -13) 📝 `packages/sso/src/saml.test.ts` (+165 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes SAML callback trust checks to prevent auto-linking accounts unless the provider is trusted or the domain is verified. This blocks unintended links and redirects with error=account_not_linked when trust is missing. - **Bug Fixes** - For existing users, only create an account link if the provider is in trustedProviders or domainVerified and the email domain matches; otherwise redirect with error=account_not_linked. - Removed unconditional account linking on callback; now respects accountLinking trust rules. - Added tests covering deny (untrusted provider, unverified domain) and allow (trusted provider) scenarios. <sup>Written for commit ce4e81154a2b71497d879cfc1833f12fc9eddcec. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> This fixes https://github.com/better-auth/better-auth/issues/6481 --- <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-15 21:53:00 -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#23641