Repository navigation
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 6d56542 | Nov 18 2026, 03:16 PM |
tnkuehne
force-pushed
the
feat/sso-multiple-domains
branch
2 times, most recently
from
November 18, 2026 14:20
142fee5 to
531f3cf
Compare
tnkuehne
force-pushed
the
docs/sso-multiple-domains
branch
from
November 18, 2026 14:21
ddd8e19 to
86d2b52
Compare
tnkuehne
force-pushed
the
docs/sso-multiple-domains
branch
from
November 18, 2026 14:31
86d2b52 to
8e9e8d4
Compare
tnkuehne
added a commit
that referenced
this pull request
Nov 18, 2026
## Problem
A company SSO provider holds exactly one email domain. The session hook
verifies an SSO address only when its domain matches that domain.
Identity providers can return addresses on other domains of the same
company, for example a Google Workspace with secondary domains. Those
users get unverified accounts. A later personal "Sign in with Google"
finds the account by email and cannot link it, so it fails with
`email_verification_required`.
## Change
Every company email domain is proven separately by DNS. Domains have
their own list and status, as in WorkOS organization domains and
Linear's approved email domains.
**Data**
- New table `sso_domain`, one row per domain with its own TXT token and
`verified_at`.
- Verified domains are mirrored into `sso_provider.domain`, the
comma-separated value Better Auth already reads. Before any domain is
verified, the pending ones are mirrored instead. Better Auth's trust and
linking decisions, email-first discovery and the session hook therefore
accept every verified domain.
- Adding a domain leaves verified domains and required SSO untouched.
- Rules:
- The last domain can't be removed.
- The last verified domain can't be removed while SSO is required.
- A settings import is checked against these rules before the connection
is saved.
- Every domain write locks the provider row, so concurrent verifications
mirror the complete list.
- Organizations that control the same DNS can still verify a shared
domain, as before. Email-first discovery then asks for the organization
link.
- Providers verified through Better Auth before this change list their
domains only in `sso_provider`. Those domains are adopted as verified,
so tracking domains never revokes an existing proof.
**Migration `0033_sso_domains`**
- Seeds domains from existing providers.
- Keeps a pending Better Auth token valid, so already published records
still verify. The record name `_better-auth-token-<provider>.<domain>`
is unchanged, and the `identifier=value` form is accepted too.
- Accounts created earlier on a newly verified domain become verified on
their next company sign-in.
**API and CLI**
- `POST /settings/domains` and `DELETE /settings/domains/{domain}` add
and remove a domain.
- `POST /settings/verify-domain` takes an optional `{ domain }`. Without
a body it verifies every pending domain, which is what released CLIs
send.
- `GET /settings` adds `ssoDomains` with status and the DNS record per
pending domain.
- `domain-verification` returns the pending domains in `records`; the
top-level fields stay for older clients.
- In settings files, `sso.domain` stays a comma-separated list. It is
required to register a connection; later it replaces the list when
present. CLI export and apply keep working unchanged.
**UI**
- New **Email domains** tab: one row per domain with status and
**Verify** / **Remove**.
- **Add domain** and **Verify** open a dialog showing the TXT record
(type, name, value, each copyable).
- The company SSO form asks for a domain only on first setup. Without a
verified domain, **Company sign-in** links to the new tab.
- Errors appear in the dialog or the row they concern. Status messages
reset when switching tabs.
- `CopyValue` now uses a new `CopyButton`, which the record rows reuse.
**Google Workspace app identity** keeps a single domain. App sign-in
sends one `hd` hint and checks the `hd` claim against it.
## Tests
- **Contracts:** domain list parsing and its limits.
- **`company-sso-plugin.integration.test.ts`:**
- per-domain tokens and partial verification;
- required SSO staying active while domains are added;
- removal rules, the legacy record format, and shared domains across
organizations;
- concurrent verification of two domains;
- a rejected import that leaves the connection unchanged;
- CLI-style verification without a domain.
- **`sso-membership.integration.test.ts`:** an alias user is verified on
their next SSO sign-in.
- **`sign-in-discovery.integration.test.ts`:** exact routing of every
listed domain.
- **`organization-settings.integration.test.ts`:** a Google app identity
with several domains is rejected.
- **E2E:**
- `onboarding.spec.ts`: add a domain with validation, show the record
dialog, remove a domain, and re-create the connection.
- `setup.spec.ts`: a failed then successful verification in the dialog;
a migrated connection without a domain; and API verification without a
body.
- **Local runs:** `pnpm check`, full `vitest run` (1056 passed), and
`test:e2e` without the CLI and source suites (75 passed).
## Visual review
- **Goal:** manage several domains without a long page. Each domain
shows its own status, and the DNS record appears only when it is needed.
- **Views checked at 1280 px and 390 px, in light and dark themes**
(Playwright screenshots from the E2E fixtures):
- pending list
- verified list with success message
- record dialog
- add dialog with validation error
- Company sign-in tab without a verified domain
- **Fixed during review:**
- domain names truncated at 390 px; the domain now gets its own line;
- the stale "Settings saved." banner after switching tabs;
- a duplicate close action in the dialog.
- **Not verified:** keyboard-only use of the dialog. It uses the shared
shadcn Dialog with focus handling and a submit form.
### Screenshots
**Before → after: Company sign-in before a domain is verified.** The DNS
record moves out of this tab.
| Before | After |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/before-verification-1280-light.png"
alt="Before: verification card with record" width="400"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-identity-unverified-1280-light.png"
alt="After: link to Email domains" width="400"> |
**Email domains tab** (1280 px)
| Pending | Verified |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-pending-1280-light.png"
alt="Pending domains, light" width="400"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-verified-1280-light.png"
alt="Verified domain, light" width="400"> |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-pending-1280-dark.png"
alt="Pending domains, dark" width="400"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-verified-1280-dark.png"
alt="Verified domain, dark" width="400"> |
**Dialogs** (1280 px)
| DNS record | Validation error |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-record-1280-light.png"
alt="Record dialog, light" width="400"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-add-error-1280-light.png"
alt="Add dialog with error, light" width="400"> |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-record-1280-dark.png"
alt="Record dialog, dark" width="400"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-add-error-1280-dark.png"
alt="Add dialog with error, dark" width="400"> |
**Mobile** (390 px)
| Pending, light | Pending, dark | Record, light | Record, dark |
| --- | --- | --- | --- |
| <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-pending-390-light.png"
alt="Mobile pending, light" width="180"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-list-pending-390-dark.png"
alt="Mobile pending, dark" width="180"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-record-390-light.png"
alt="Mobile record, light" width="180"> | <img
src="https://raw.githubusercontent.com/widefleet/widefleet/9a13dcfe434856e9d07f461334ca2a290e3edec7/after-dialog-record-390-dark.png"
alt="Mobile record, dark" width="180"> |
Documentation: #205 (draft, publish after release).
tnkuehne
force-pushed
the
docs/sso-multiple-domains
branch
from
November 18, 2026 15:13
8e9e8d4 to
6d56542
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the individually verified company SSO email domains from #204.
Guide: verification moves to Settings → Email domains, and a new Add more email domains section explains:
It also notes the single-domain limit for Google app identity.
Settings reference:
domainis a comma-separated list with replace-or-omit semantics and a limit of 20 domains.verify-domainverifies every pending domain, anddomain-verificationreturnsrecords.API reference:
POST /settings/domains,DELETE /settings/domains/{domain},ssoDomains, andverify-domainwith an optional domain.#204 is merged; this branch is rebased onto
mainand contains only documentation.Publication blockers: a published release that includes #204.