[PR #7541] [MERGED] feat(sso): support multi-domain providers #32988

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7541
Author: @Paola3stefania
Created: 1/22/2026
Status: Merged
Merged: 1/22/2026
Merged by: @himself65

Base: canaryHead: fix/sso-multi-domain-comma-separated


📝 Commits (1)

  • e6c87f0 feat: comma separeted domains

📊 Changes

4 files changed (+194 additions, -42 deletions)

View changed files

📝 packages/sso/src/linking/org-assignment.ts (+18 -3)
📝 packages/sso/src/routes/sso.ts (+55 -34)
packages/sso/src/utils.test.ts (+103 -0)
📝 packages/sso/src/utils.ts (+18 -5)

📄 Description

address https://github.com/better-auth/better-auth/issues/7324

Summary by cubic

Enable enterprise multi-domain SSO by allowing comma-separated domains in ssoProvider.domain and updating validation and lookups to match subdomains. This lets one IdP cover multiple email domains and correctly assign users to organizations.

  • New Features
    • Accept comma-separated domains in ssoProvider.domain (e.g., "company.com,subsidiary.com").
    • Added domainMatches and updated validateEmailDomain to support lists, subdomains, and case-insensitive matching.
    • Updated sign-in and org assignment to try exact domain first, then match within comma-separated lists across providers.
    • Clarified API schema description for the domain field.
    • Added unit tests for multi-domain validation and edge cases.

Written for commit e6c87f0aab. Summary will update on new commits.

// Register provider with multiple domains
await auth.api.registerSSOProvider({
  body: {
    providerId: "okta-enterprise",
    issuer: "https://company.okta.com",
    domain: "company.com,subsidiary.com,acquired-company.com",
    // ... config
  }
});

// All these now work:
authClient.signIn.sso({ email: "user@company.com", callbackURL: "/" })
authClient.signIn.sso({ email: "user@subsidiary.com", callbackURL: "/" })
authClient.signIn.sso({ domain: "acquired-company.com", callbackURL: "/" })
authClient.signIn.sso({ providerId: "okta-enterprise", callbackURL: "/" })

🔄 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/7541 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 1/22/2026 **Status:** ✅ Merged **Merged:** 1/22/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/sso-multi-domain-comma-separated` --- ### 📝 Commits (1) - [`e6c87f0`](https://github.com/better-auth/better-auth/commit/e6c87f0aab73326312a7de7b57fd93a9d48f4b8e) feat: comma separeted domains ### 📊 Changes **4 files changed** (+194 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `packages/sso/src/linking/org-assignment.ts` (+18 -3) 📝 `packages/sso/src/routes/sso.ts` (+55 -34) ➕ `packages/sso/src/utils.test.ts` (+103 -0) 📝 `packages/sso/src/utils.ts` (+18 -5) </details> ### 📄 Description address https://github.com/better-auth/better-auth/issues/7324 <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Enable enterprise multi-domain SSO by allowing comma-separated domains in ssoProvider.domain and updating validation and lookups to match subdomains. This lets one IdP cover multiple email domains and correctly assign users to organizations. - **New Features** - Accept comma-separated domains in ssoProvider.domain (e.g., "company.com,subsidiary.com"). - Added domainMatches and updated validateEmailDomain to support lists, subdomains, and case-insensitive matching. - Updated sign-in and org assignment to try exact domain first, then match within comma-separated lists across providers. - Clarified API schema description for the domain field. - Added unit tests for multi-domain validation and edge cases. <sup>Written for commit e6c87f0aab73326312a7de7b57fd93a9d48f4b8e. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> ``` // Register provider with multiple domains await auth.api.registerSSOProvider({ body: { providerId: "okta-enterprise", issuer: "https://company.okta.com", domain: "company.com,subsidiary.com,acquired-company.com", // ... config } }); // All these now work: authClient.signIn.sso({ email: "user@company.com", callbackURL: "/" }) authClient.signIn.sso({ email: "user@subsidiary.com", callbackURL: "/" }) authClient.signIn.sso({ domain: "acquired-company.com", callbackURL: "/" }) authClient.signIn.sso({ providerId: "okta-enterprise", callbackURL: "/" }) ``` --- <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:40:56 -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#32988