Skip to content

Configure verified company SSO per organization - #68

Merged
tnkuehne merged 6 commits into
feat/email-code-sign-infrom
feat/verified-company-sso
Oct 22, 2026
Merged

tnkuehne merged 6 commits into
feat/email-code-sign-infrom
feat/verified-company-sso

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Configure company SSO through Better Auth's native SSO provider and use one company registration for both the control plane and deployed apps. An administrator enters issuer, domain, client ID and secret once and registers the two displayed callbacks. Apps authenticate directly with the company provider; they do not call the control plane during that login.

The native sso_provider row is the sole editable source for the connection. Its encrypted OIDC configuration owns credentials, discovery and all claim mappings, including app groups through oidcConfig.mapping.extraFields.groups. The native provider additional field appIdentityType selects OIDC or Entra app identity handling and is saved in the same native provider transaction. organization_settings stores the optional Microsoft Graph directory client and encrypted secret directly on its row, the external-management flag and the separate sso_required policy flag. Directory inputs use clientSecret; omission preserves it and removing the directory clears it. The generic secret-reference table and its cleanup code are removed. There is no second editable provider/management/app-client document and no credential synchronization between two stores.

UI, API and CLI share the native provider input. The settings page has one credentials form; CLI export includes the redacted native connection. Omitting the secret preserves the saved value. Native register/update/delete APIs perform provider mutations using the caller's existing authentication instance, outside the surrounding settings transaction. The former custom discovery and delete/recreate replacement path are removed. Native updates reject issuer/client-identity changes when accounts are linked instead of silently deleting their bindings. File bootstrap signs in the local owner and uses that same API. installation.bootstrap_pending is set atomically when the file creates the owner and cleared after successful initialization. Failed initialization resumes with that owner; completed initialization ignores a stale or removed file.

The one-time migration converts the old installation identity document, keeps an existing native provider authoritative, preserves directory credentials and removes obsolete duplicate secrets. With an older separate app registration, the former management registration becomes the shared registration: its app callback must be added before republishing. Earlier configurations have no DNS ownership proof and require verification. Recovery remains available.

Other behavior in this SSO layer:

  • One provider and one verified company domain per organization. Native organization provisioning enrolls provider-admitted users, including external guests, as members without a separate invitation. Existing memberships keep their roles; pending invitations retain native acceptance and their invited role. Better Auth retains its account-linking trust rules: an external email claim alone cannot link an existing account. Company sessions and CLI tokens retain the organization that authenticated them.
  • Browser/API/CLI administration checks current organization authority. Existing CLI JWTs are adapted into an invocation-only context for native management APIs; no browser session is created. Direct plugin management HTTP routes remain closed so the shared service policy applies consistently.
  • Runtime publication, app group authorization and organization-specific callback/session isolation remain Widefleet responsibilities. Microsoft Graph search credentials are separate from the shared login registration; no directory synchronization or SCIM is added.
  • Provider changes and removal do not automatically revoke existing company sessions or refresh grants. Native provider mutation safeguards remain in place. The existing device authorization patches retain approving-session and consent references; older tokens require login again.
  • Unpublished SSO configuration shows a waiting state. The company chooser remains accessible with or without default company/email login. Concurrent native settings saves do not hold an outer settings connection while waiting on the authentication pool.

DNS verification permits an optional test login. Administrators explicitly activate mandatory SSO through Settings, POST /api/v1/settings/activate-sso or widefleet settings activate-sso. No persisted test-login proof is required. Until activation, email access remains available. The existing first-install password completion flow retains its administrator test and disables password access when completed.

The native provider scopes are also sent by app sign-in. Re-enabling browser settings management no longer gets undone by saving an older form draft. Shared CLI authentication retains its scoped OAuth tokens and invocation-only plugin context; duplicated administrator-role checks in that bridge are removed. The restart confirmation and external-management modes remain.

Overlapping saves keep provider credentials, app identity mode and claim mappings in one native provider row. Directory/external-management settings are still separate writes; the entire settings form is not one transaction. Re-verifying a previously activated provider republishes its current app configuration. Email sign-in before SSO activation continues to the requested destination, and the local demo explicitly activates its synthetic provider.

Validation: workspace type checks, formatting and type-aware lint; focused SSO/settings/migration integration tests, including provider-outage bootstrap recovery, overlapping saves and DNS re-verification; 540 default tests across the stack; browser setup and onboarding; 49 real CLI tests; composed Cloudflare build. Tests exercise real authorization-code callbacks with local PostgreSQL and synthetic providers: uninvited company users and external guests, repeat login, trusted company-account linking, rejected linking of an existing external account, pending invitations, disabled organization admission, and retained sessions/refresh grants after provider removal. Existing browser/CLI authority and direct company app-login tests remain in place.

Review order: #65 → #66 → #68 → #69 → #70 → #63 in native GitHub stack #67. Product documentation is in #58 and remains blocked on a published release.

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

The PR appears safe to merge with the remaining overlapping-save limitation explicitly accepted.

Summary

This PR gives each organization one native SSO connection shared by the control plane and deployed apps.

  • Organization settings use one verified SSO connection for Widefleet and deployed apps.
  • Company sign-in keeps each session and CLI token tied to its organization.
  • Deployed apps sign in through the shared provider with organization-specific routes and sessions.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Administrator saves company connection] --> B[Native SSO provider]
  B --> C[Verify company domain]
  C --> D[Optional test login]
  C --> E[Explicitly activate SSO]
  E --> F[Publish shared registration to apps]
  B --> G[Company control-plane login]
  G --> H[Organization-scoped session and CLI tokens]
  F --> I[Apps sign in directly with company provider]
Loading

Reviews (6) · Last reviewed commit: "Keep native provider claims atomic and r..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 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 11f7c50 Oct 22 2026, 12:34 AM

@tnkuehne
tnkuehne force-pushed the feat/verified-company-sso branch from fa913f1 to 333807b Compare October 21, 2026 18:02
@tnkuehne
tnkuehne force-pushed the feat/verified-company-sso branch from 110fda7 to fa47fca Compare October 21, 2026 23:50
@tnkuehne
tnkuehne merged commit ac2ffc9 into main Oct 22, 2026
27 of 29 checks passed
@tnkuehne
tnkuehne deleted the feat/verified-company-sso branch October 22, 2026 13:16
tnkuehne added a commit that referenced this pull request Oct 22, 2026
Move login, app-login and directory settings from the installation row
into organization-owned settings and encrypted secrets. Settings
services and directory searches use the selected organization; saving
one organization's settings cannot resolve or delete another
organization's secrets. The migration preserves existing installation
settings and credentials under the existing installation organization.

This is the transitional storage relocation layer extracted from #63. It
moves the existing settings document without establishing that document
as the final SSO model: #68 converts it into the native Better Auth
provider and removes the duplicate identity fields. It does not yet add
organization-specific company login or app authentication. Those follow
in the SSO and app-sign-in layers. Existing installation login and app
publication keep their current behavior in this intermediate state.

Decisions included here:
- Organization administrators can access their own settings without
installation-wide administration rights. Reporting, runtime
administration and finishing installation setup retain
installation-admin checks.
- Secrets remain encrypted with the installation encryption key, with
organization ownership enforced by the service queries. Directory
clients and cached access tokens are separated by organization and
refreshed when credentials change.
- Settings publication is serialized per organization. The service keeps
a shared revision to invalidate request snapshots after writes.

Validation: workspace type checks, formatting and type-aware lint;
control-plane production build; default Vitest suite (470 applicable
tests, with the two affected authorization fixtures updated and rerun
successfully). Includes foreign-secret rejection, preserving unrelated
settings, directory isolation, settings publication and migration tests.
Local services and synthetic fixtures only.

Review order: #65 → #66 → #68 → #69 → #70 → #63 in native GitHub stack
#67. Product documentation stays in #58 and must wait for a published
release.

The organization settings page now separates installation-only reporting
in this layer. Its browser regression test passes both here and at the
stack tip. Upgrade coverage for existing settings, secret identifiers
and ciphertext is included with this migration.
tnkuehne added a commit that referenced this pull request Oct 22, 2026
Allow admitted members and invitees to sign in with a code sent to their
email address. The sign-in screen uses Better Auth's email OTP plugin;
the existing password and company-provider login remain available in
this layer. Unknown or non-admitted addresses receive the same send
response without an email or a new account.

Extracted from #63; builds on #65. Invitations and organization-specific
SSO are separate layers. Email delivery is injectable for Node
integrations and uses the optional Cloudflare Email binding on Workers.
No email sender means the code flow is disabled.

Decisions included here:
- Codes last five minutes and allow three failed attempts. Better Auth
hashes stored codes and owns their validation and attempt counter.
- Request limits use Better Auth's in-memory storage on Node and
Cloudflare rate-limit bindings on Workers. There is no rate-limit
database table. Workers trust CF-Connecting-IP; counters are local to
Cloudflare locations, not a global customer quota.
- The Cloudflare device lookup policy is five requests per minute
because its bindings support 10/60-second windows. This does not change
device-code expiry. Wrangler declares all required bindings.
- Existing Better Auth/OAuth packages move from 1.7.7 to 1.7.12 for the
native atomic limiter interface. The obsolete type-only patch and
SvelteKit peer exception are removed. The separate SSO layer contains
the device-authorization patch.

Validation: `pnpm check`, Node and Cloudflare production builds, all 482
applicable default Vitest tests. Tests capture email locally and
exercise real OTP admission, successful sign-in, exhausted-code
rejection, independent request policies and local Cloudflare bindings.
No live mail or deployment.

Review order: #65 → #66 → #68 → #69 → #70 → #63 in native GitHub stack
#67. Product documentation stays in #58 and must wait for a published
release.


<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=85373076"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/mendra/github/widefleet/widefleet/-/pull/66"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier:
plus" title="Review tier: plus"
src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-plus.svg?v=3"
height="12"></sup></h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge with
non-blocking issues, including sign-in errors that reveal admitted
addresses.

<h2>Findings</h2>

1. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;<img alt="Security"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2"
align="top">&nbsp;**Errors reveal admitted addresses** <a
href="https://github.com/widefleet/widefleet/pull/66#discussion_r4340308772">▶</a>
2. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Mixed\-case emails receive no code** <a
href="https://github.com/widefleet/widefleet/pull/66#discussion_r4340040151">▶</a>
3. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Requested email can still change** <a
href="https://github.com/widefleet/widefleet/pull/66#discussion_r4340040158">▶</a>
4. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Invitation admission lacks test coverage** <a
href="https://github.com/widefleet/widefleet/pull/66#discussion_r4340040164">▶</a>

<details open><summary><h3>Summary</h3></summary>

Adds email-code sign-in for admitted members and invitees, with
injectable delivery and native request limits.

- Admitted members and invitees can sign in with a code sent to their
email.
- Authentication requests use rate limits suited to Node and Cloudflare.

Tests and browser checks were not run. Dependencies and a built
application were absent.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
sequenceDiagram
  participant User
  participant Page as Sign-in page
  participant Auth as Better Auth
  participant Admission
  participant Email
  User->>Page: Enter email
  Page->>Auth: Request sign-in code
  Auth->>Admission: Check membership or invitation
  alt Address admitted
    Auth->>Email: Send five-minute code
  end
  Auth-->>Page: Success
  User->>Page: Enter code
  Page->>Auth: Sign in with email and code
  Auth->>Admission: Check admission again
  alt Address admitted
    Auth->>Auth: Check code and attempt count
    Auth-->>Page: Session or invalid-code error
  else Address denied
    Auth-->>Page: Separate unauthorized error
  end
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (3) · Last reviewed commit: ["Include native rate-limit
bindings in
Cl..."](281b5c2)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Oct 22, 2026
Invite people, accept or cancel invitations, change roles and remove
members through the browser, HTTP API and CLI. Shared services call
Better Auth's organization APIs using the existing authentication
instance. Widefleet enforces organization admission, company-SSO
authority and stale browser selection; the plugin owns role checks and
membership mutations.

Behavior:
- Native invitation defaults apply: 48-hour expiry, 100 members and 100
pending invitations per organization. A duplicate pending invite is
rejected; cancel it before replacing it.
- Invitations require the matching verified email and, after SSO
activation, company sign-in. Acceptance changes membership only; there
is no account-name field or CLI `--name` option.
- Issued invitations remain usable until acceptance, expiry or explicit
cancellation, including after the inviter is removed or demoted. There
is no extra owner-invitation cancellation/protection policy.
- Better Auth handles owner role restrictions and its last-owner check.
There is no additional organization lock, transaction-bound
authentication instance or custom concurrent-owner rule.
- Custom listing and invitation reads preserve organization and
recipient boundaries. Direct plugin management HTTP routes remain
closed; UI/API/CLI use the same public services and the existing scoped
OAuth credentials.
- Provider-admitted users may join through native SSO provisioning
without an invitation. Removing membership does not revoke their IdP
assignment. Initial customer admission remains an operator operation.

Validation: full stack type checks, formatting and type-aware lint; 536
default tests; 49 tests with the real CLI; browser onboarding and
invitation acceptance. Tests cover native limits, expiry, role checks,
invitations surviving inviter demotion, membership-only acceptance and
cross-organization denial.

Review order: #65 → #66 → #68 → #69 → #70 → #63 in native GitHub stack
#67. Documentation is in #58 and waits for a published release.








<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=85384822"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/mendra/github/widefleet/widefleet/-/pull/69"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge, with two
non-blocking concerns from the previous review still open.

<h2>Findings</h2>

1. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Failed emails block retries** <a
href="https://github.com/widefleet/widefleet/pull/69#discussion_r4343195622">▶</a>
2. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Admins lose the revoke action** <a
href="https://github.com/widefleet/widefleet/pull/69#discussion_r4343415998">▶</a>

<details open><summary><h3>Summary</h3></summary>

Adds organization invitations and member management across the browser,
HTTP API, and CLI.
- Organization admins can change roles and remove members across
clients.
- Organization admins can invite people and recipients can accept by
email.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  UI[Browser] --> Services[Shared member and invitation services]
  API[HTTP API] --> Services
  CLI[CLI] --> API
  Services --> Auth[Better Auth]
  Auth --> DB[(Organization membership)]
  Services --> Email[Invitation email]
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (8) · Last reviewed commit: ["Trace browser network test
progress in
C..."](df6b881)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Oct 22, 2026
…#70)

Allow people without company SSO to sign in to their deployed apps
through Widefleet's existing Better Auth OAuth provider. The app runtime
uses an OIDC configuration just as it does with a company provider; it
validates its own app sessions. Verified company SSO continues to send
the runtime directly to that provider using the same native company
registration as the control plane.

This is the app-login layer extracted from #63, following #69. It adds
fallback client provisioning, publication and authorization to the
organization-specific app-login paths introduced in #68.

Behavior and implementation choices retained from #63:
- One confidential OAuth client per organization, with PKCE, a fixed
organization-specific callback and no extra consent dialog. The OAuth
provider stores a hash of the client secret; organization settings
retain an encrypted copy for runtime configuration.
- App tokens require verified email, current membership and an admitted
organization. A company-authenticated identity cannot obtain another
organization's app token. Enabling activated company SSO disables that
organization's Widefleet fallback client.
- Client provisioning and runtime publication occur during email-enabled
setup and organization settings publication. Retryable reads reuse the
existing secret. The migration adds the encrypted client-secret column
separately from organization settings and SSO storage.
- New fallback logins require the control plane. Already-issued app
sessions remain usable during a control-plane outage; direct company SSO
retains its separate login path.

Validation: workspace checks and production builds at the stack tip; 39
focused invitation, OAuth, SSO and organization settings integration
tests at this layer. Covers real redirects/tokens, app proxy,
cross-organization access, native provider updates, disabling/restoring
fallback credentials and publication retries. One CLI test is opt-in and
covered by the separate executable CLI run.

Review order: #65 → #66 → #68 → #69 → #70 → #63 in native GitHub stack
#67. Product documentation stays in #58 and must wait for a published
release.

DNS verification alone preserves the Widefleet app-login fallback.
Explicit company-SSO activation switches apps to the shared company
registration and disables the built-in client. Existing per-organization
OAuth client provisioning and scoped CLI credentials are unchanged.










<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=85386307"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/mendra/github/widefleet/widefleet/-/pull/70"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier:
plus" title="Review tier: plus"
src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-plus.svg?v=3"
height="12"></sup></h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge with PR
#63’s hosted setup fix; the remaining test-coverage suggestion is
non-blocking.

<h2>Findings</h2>

1. <img alt="P2"
src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9"
align="top">&nbsp;**Signed\-out login lacks coverage** <a
href="https://github.com/widefleet/widefleet/pull/70#discussion_r4340215234">▶</a>

<details open><summary><h3>Summary</h3></summary>

Adds Widefleet app sign-in when company SSO is not active.
- Organizations can use Widefleet to sign people in to deployed apps
when company SSO is inactive.
- Admins can switch app sign-in between Widefleet and company SSO.

Tests were inspected, not run. Runtime and visual checks were
unavailable because dependencies and build artifacts are absent.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
sequenceDiagram
  participant Browser
  participant App as App runtime
  participant Widefleet
  participant Company as Company provider
  alt Company SSO is active
    Browser->>App: Open app
    App->>Company: Start company sign-in
    Company-->>App: Return authorization code
    App->>Company: Exchange code without Origin
  else Widefleet fallback
    Browser->>App: Open app
    App->>Widefleet: Start organization app sign-in
    Widefleet-->>Browser: Request sign-in if needed
    Widefleet-->>App: Return authorization code
    App->>Widefleet: Exchange code with PKCE and Origin
    Widefleet->>Widefleet: Check email, membership and organization access
    Widefleet-->>App: Return organization-scoped identity
  end
  App-->>Browser: Issue app session
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (9) · Last reviewed commit: ["Restrict token request Origin
to the
bui..."](a74a546)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Oct 22, 2026
Compose a hosted control-plane build with an optional runtime extension
supplying organization admission and email delivery. The standard public
build uses its self-contained default. Node and Cloudflare
initialization use the same extension contract and publish app-login
configuration during email-enabled setup.

This PR is now only the final layer extracted from the former combined
#63. Review the native GitHub stack in order:
1. #65 — organization settings, secrets and directory storage
2. #66 — email-code login and native rate limits
3. #68 — verified company SSO and organization-specific company app
login
4. #69 — members and invitations across UI/API/CLI
5. #70 — Widefleet OAuth fallback for deployed apps
6. #63 — hosted runtime composition and configuration

This layer exposes the package APIs required by composition, selects the
extension at build time, and generates versioned Cloudflare
configuration for email, limiter namespaces, the shared wildcard app
route and control-plane domain. Initialization publishes default
app-login configuration when email is enabled. Source-run initialization
and operator commands load the same selected runtime extension as the
build and prefer its email sender over native bindings. It removes the
repository-specific hosted deployment workflow and installation profile;
generic public Cloudflare build/deploy tooling remains available.

The browser acceptance test runs the selected extension through Vite
development mode against synthetic organizations/providers and a local
email sink. It covers invitation acceptance, organization isolation,
member management, required company sign-in, fallback activation
recovery and removal/recreation of native SSO settings. Production Node
and Cloudflare builds are checked separately; the browser test does not
exercise a composed production artifact. Nothing is deployed by this
change; DNS/TLS availability and production credentials still belong to
the deployment process.

The underlying SSO layer now uses the native Better Auth provider as its
only editable connection, with one registration shared by the control
plane and app runtime. Bootstrap and composed onboarding consume that
contract. Existing product choices and remaining custom auth
integrations are identified in their owning PRs. In particular, #68
calls out immediate SSO activation after DNS proof. Native SSO
provisioning enrolls provider-admitted users, including external guests,
without a separate invitation, while preserving native account-linking
safeguards. Provider changes do not automatically revoke existing
sessions or refresh grants.

Validation: workspace type checks, formatting and type-aware lint;
standalone Node and Cloudflare builds; default integration tests and
browser acceptance tests; comparison of the original and split database
migrations. Tests use local services and synthetic data. The
extension-only email regression reproduces the previous missed
bootstrap, then verifies the actual initialization subprocess registers
its app OAuth client and publishes through a local Workerd service
binding without native email bindings; all seven focused bootstrap tests
pass.

Documentation: #58 remains separate and blocked on a published release
including the stack and matching CLI/agent/runtime artifacts.


















<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=84719389"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/mendra/github/widefleet/widefleet/-/pull/63"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> The changes since the previous review
appear safe to merge; no new actionable issue was found.

<details open><summary><h3>Summary</h3></summary>

Adds build-time runtime extensions for organization access and email,
with matching support in Node and Cloudflare initialization.
- Node and Cloudflare runtimes can use the same optional extension.
- Hosted worker settings can set email senders and separate rate limits.
- The repository-specific hosted deployment workflow and profile are
gone.
- The oversized-upload test sends just past the runtime's limit.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Selection[Selected runtime extension] --> Build[Vite build]
  Selection --> Commands[Source-run initialization]
  Build --> Node[Node runtime]
  Build --> Cloudflare[Cloudflare runtime]
  Commands --> Bootstrap[Email-enabled bootstrap]
  Bootstrap --> Register[Register app login]
  Register --> Publish[Publish app configuration]
  Node --> Services[Organization access and email]
  Cloudflare --> Services
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (17) · Last reviewed commit: ["Test early KV rejection at
the exact
str..."](29bd9b6)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
tnkuehne added a commit that referenced this pull request Nov 25, 2026
Removes the startup conversion of the company SSO configuration that
releases before 0.4.0 stored in
`organization_settings.settings.identity`.

## Changes

- **Conversion removed.** `sso-migration.ts` (`migrateSsoSettings`) is
deleted, with its calls in Node startup (`runtime-initialization.ts`)
and Hosted initialization (`tools/cloudflare-initialization.ts`).
- **Identity document support removed:**
  - the `legacy-sso-client-secret` secret context
  - the leftover identity document location in secret re-encryption
- **Guard migration `0046_require_converted_sso`.** Startup refuses to
continue while any `organization_settings` row still has an `identity`
key, including `identity: null`. Its message:

> Company SSO settings still use the configuration format of earlier
releases. Start the previous release once so it converts the earlier SSO
configuration, then upgrade.

`0044_require_jwe_secrets` still checks the identity document's client
secret and is unchanged.

## Upgrade path

The conversion first shipped in **0.4.0** (#68). Every release from
0.4.0 up to this change runs it at startup, for Node and Hosted
installations.

Installations upgrading from a release before 0.4.0 must first start a
release with the conversion (0.4.0 or newer, before this change) once,
so it converts the earlier SSO configuration. Then they can upgrade to a
release with this change. Their stored secrets also fall under the
requirement of `0044_require_jwe_secrets` (#399).

Installations already on 0.4.0 or newer have no identity document left
and pass the guard.

## Testing

- `pnpm check`
- `tests/sso-conversion-guard.integration.test.ts` (new): a row with an
identity document or `identity: null` aborts with the message; the
converted settings pass.
- `tests/secret-reencryption.integration.test.ts`: without the identity
document cases. The paging case is removed: it exercised the only
location that skipped rows without a ciphertext.
- `tests/jwe-secret-guard.integration.test.ts`,
`tests/settings.integration.test.ts`,
`tests/runtime-errors.integration.test.ts`,
`tests/email-setup.integration.test.ts`
- `RUN_CLOUDFLARE_TESTS=1 vitest run
tests/cloudflare/initialization.test.ts`
- `tests/e2e/setup.spec.ts` (Playwright): the upgrade scenario that
modeled an identity document and called the conversion is removed. The
rest of the test passes.


<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge with
the stated staged upgrade requirement.</rp></ruby><a
href="https://app.greptile.com/api/retrigger?id=120014892&amp;sig=61f14a6ad9b328c14a763df6075dfaa346dacde9c723e8f71e10f30c95755275"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F415&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5 <sup><img alt="Tier:
plus" title="Review tier: plus"
src="https://greptile-static-assets.s3.amazonaws.com/badges/effort-plus.svg?v=3"
height="12"></sup></h2>

<!-- greptile-impact-verdict --> The PR appears safe to merge with the
stated staged upgrade requirement.

<details open><summary><h3>Summary</h3></summary>

Removes startup conversion of pre-0.4.0 company SSO settings.
- Upgrades now stop until old company sign-in settings are converted.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Node startup or Hosted setup"] --> B["Run database migrations"]
  B --> C{"Settings contain identity?"}
  C -->|Yes| D["Stop: start the previous release once"]
  C -->|No| E["Initialize installation"]
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (1) · Last reviewed commit: ["Remove the conversion of the
pre-0.4.0
S..."](2ea9a0b)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
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