Skip to content

Require company SSO for every sign-in of a company address - #306

Merged
tnkuehne merged 4 commits into
mainfrom
company-sso-domain-rule
Nov 23, 2026
Merged

tnkuehne merged 4 commits into
mainfrom
company-sso-domain-rule

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

An organization with company SSO proves its email domains through DNS. Since #291, its SSO session also reaches the person's other memberships for an address on those domains. The company still did not own sign-in for these addresses:

  • An email code sent through an organization link or the API signed them in.
  • Google and Microsoft signed them in.

The resulting personal session reached every membership without passing the company's sign-in. Required SSO protected only the organization itself.

Change

Organizations with active company SSO now own sign-in for their verified domains, as WorkOS domain policies do.

Setting

  • New column organization_settings.domain_sso_required (migration 0040_domain_sso).
  • Activating company SSO turns it on; removing the connection turns it off. The migration copies sso_required, so organizations that already require SSO keep that requirement for their domains.
  • Administrators switch it on the Company sign-in page, with PUT /api/v1/settings/domain-sso or with widefleet settings domain-sso true|false. Turning it on requires active SSO and a verified domain. GET /settings adds domainSsoRequired.
  • The rule applies only to DNS-verified domains of an organization the installation admits. An operator-trusted provider without DNS proof does not claim addresses.

Enforcement

  • Session creation rejects a personal session for such an address with COMPANY_SSO_REQUIRED and the provider ID. Every personal sign-in method passes this check. Company SSO, another organization's SSO for a guest, and recovery stay available.
  • Email codes: send-verification-otp and sign-in/email-otp return the same error, so no code is sent. The sign-in form continues with company SSO, as the email field already does.
  • Google and Microsoft: validateUserInfo rejects the address before any user, account or session is created. The callback returns to /sign-in/connect with error=company_sso_required and an encrypted, 10-minute hint (symmetricEncodeJWT with the auth secret). The page decrypts it and starts company SSO with the address as login hint and the original next, so OAuth and device continuations survive. A loop guard falls back to a button.
  • One organization per domain: verifying a domain that another organization has already verified fails with a conflict. Earlier, organizations that controlled the same DNS could both verify a domain; that was kept in Verify company SSO email domains individually #204 to avoid a failing unique-index migration. The check runs at verification and needs no index. With shared domains, an address would have had two company sign-ins.
  • Existing sessions and CLI grants stay valid until they end.
  • Joining by email domain (Let people join organizations through their company email domain #300): these addresses can no longer prove their domain through Google or Microsoft. A linked company SSO account of the organization that verified the domain by DNS now proves it instead, so its administrators can still open organizations to the domain.

UI

  • New section Company addresses use SSO only with a switch on the Company sign-in page. The switch is optimistic: a failed change returns to the previous state and explains why in a toast. The shared Toaster and toast export are the same lines as in Save member roles optimistically on selection #288.
  • /sign-in/connect gets a Continue with company SSO state.

Tests

  • social-sign-in.test.ts:
    • Google and Microsoft, for existing and new users, return the encrypted hint without the address in the URL and create nothing.
    • Email code send and verify return COMPANY_SSO_REQUIRED.
  • organization-sso.integration.test.ts:
    • A personal session is rejected.
    • An address on another domain still signs in.
    • Company SSO, another organization's SSO and recovery still work.
    • A non-admitted organization, inactive SSO and a disabled rule each lift the requirement.
  • organization-settings.integration.test.ts:
    • Activation turns the rule on and administrators can turn it off and on again.
    • Removing SSO clears it; enabling without SSO conflicts.
  • company-sso-plugin.integration.test.ts:
    • Activation through settings enables the rule.
    • A domain verified by another organization is rejected.
  • cli.test.ts: settings domain-sso.
  • Local runs:
    • vitest run: 1255 passed, 667 skipped.
    • RUN_CLI_TESTS=1 CLI tests: 60 passed.
    • Control-plane svelte-check, oxlint and oxfmt on the changed files.
    • cargo fmt --check and cargo clippy -p platform-cli -D warnings.
  • Playwright E2E was not run locally; CI covers it.

Visual review

Goal: administrators see which addresses the rule covers and can switch it. A person who picks Google is taken to their company's sign-in.

Checked at 1280 and 390 px in light and dark themes, rendered with the built server and synthetic fixtures. No horizontal overflow, the switch stays aligned with the title at 390 px, and the domain list wraps.

Company sign-in, before → after (1280, light)

Before After

Switched off at once (390, dark) and narrow layout (390, light)

Off (optimistic) On

Google or Microsoft with a company address: shown only when the automatic start is skipped by the loop guard; otherwise the browser goes straight to company SSO.

390, light 1280, dark

Not checked visually: the toast after a failed switch (same component and pattern as #288), and the expired-hint state, which shows the text without the button.

Documentation: #307 (draft until a release includes this change).

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

The PR appears safe to merge with #307’s immediate switch handler included.

Summary

Requires company SSO when a personal sign-in uses an address on an admitted organization’s verified domains.

  • Administrators can require company SSO for addresses on verified domains.
  • Personal sign-ins with covered addresses continue through company SSO.
  • Each DNS-verified company domain belongs to one organization.
  • Linked company SSO can prove its verified domain for organization joining.

Tests and browser checks were not rerun.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Email code, Google, or Microsoft"] --> B{"Company SSO required for this domain?"}
  B -->|No| C["Create personal session"]
  B -->|Yes| D["Continue with company SSO"]
  D --> E["Create company session"]
  F["Other organization SSO or recovery"] --> E
  G["Other personal sign-in methods"] --> H["Check domain rule before creating session"]
  H --> B
Loading

Reviews (8) · Last reviewed commit: "Accept company SSO on a verified domain ..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs a4ed65b Nov 23 2026, 04:12 PM

@tnkuehne
tnkuehne force-pushed the company-sso-domain-rule branch from dc1f42f to 354b215 Compare November 23, 2026 09:31
An organization with company SSO proves its email domains through DNS, but
addresses on those domains could still sign in with an email code, Google or
Microsoft and reach their other memberships without the company's sign-in.

Organizations now own sign-in for their verified domains, like WorkOS domain
policies:

- organization_settings.domain_sso_required turns on when company SSO is
  activated and switches off when the connection is removed. The migration
  copies sso_required, so organizations that already require SSO keep it.
  Administrators switch it with the Company sign-in page,
  PUT /api/v1/settings/domain-sso or widefleet settings domain-sso.
- Session creation rejects a personal session for such an address with
  COMPANY_SSO_REQUIRED and the provider ID. Every personal sign-in method
  passes this check. Company SSO, another organization's SSO and recovery
  stay available.
- Email codes are not sent for these addresses. The sign-in form continues
  with company SSO instead, as the email field already does.
- Google and Microsoft return to the connect page with an encrypted hint,
  which starts company SSO for the address without showing it in the URL.
- A domain can be verified by one organization only, so its addresses have
  exactly one company sign-in.
- Existing sessions and CLI grants remain valid until they end.
- Verification locks each domain inside its transaction and checks other
  organizations' claims there, so concurrent verifications leave one claim.
- The domain rule lookup filters every matching provider by admission, so a
  shared claim from before exclusive verification still requires company SSO.
- Browser writes to the domain rule respect external management; API and
  CLI writes remain available.
- The switch saves changes in order and shows the latest choice, so a slower
  earlier save cannot overwrite it.
A save whose value matched the latest choice cleared it, so a pending
earlier save could still show an older value. Only the latest click's save
clears the local choice now.
Addresses on a domain with required company SSO cannot sign in with Google
or Microsoft, so those sign-ins can no longer prove the domain. A linked
company SSO account of an organization that verified the domain by DNS
now proves it as well.
@tnkuehne
tnkuehne force-pushed the company-sso-domain-rule branch from a4ed65b to e687348 Compare November 23, 2026 16:15
@tnkuehne
tnkuehne merged commit 0e1bfb4 into main Nov 23, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the company-sso-domain-rule branch November 23, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant