> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tuturuuu identity provider

> Design for signing internal accounts into external SaaS (Claude, GitHub, Slack, Notion) over SAML 2.0 and OIDC

> [!NOTE]
>
> **Status: approved design; slice S1 is in progress.** This page describes target
> behavior. Nothing on this page is enabled. The implemented SAML foundation (phases 1 to 4)
> and its current, binding rules are in [Outbound SSO to Claude](https://docs.tuturuuu.com/platform/features/sso.md).
> Where the two pages disagree, that page describes what ships today.

## Goal

A verified internal Tuturuuu account can sign into external systems without a
separate password: Claude first, then GitHub Enterprise, Slack, Notion, Google
Workspace-style apps and any SAML 2.0 or OpenID Connect relying party. Tuturuuu
is the **identity provider (IdP)** here. This is the reverse of inbound enterprise
sign-in to Tuturuuu, and it is separate from internal cross-app and satellite
sessions. No Tuturuuu bearer, refresh token or Supabase session ever leaves
Tuturuuu.

"Seamless" means one Tuturuuu sign-in (with MFA) and then one click per app,
including through an app launcher. "Secure" means the rules below fail closed.

## What exists today (inventory)

| Area | State on `main` | Gap for this design |
| - | - | - |
| Protocol library `packages/sso` | SAML AuthnRequest parse (Redirect/POST), pinned request signatures, signed response plus assertion (RSA-SHA256, exclusive c14n), IdP metadata, Node-SAML SP harness. No framework imports | No OIDC. Metadata publishes one certificate |
| Persistence (migrations `20261022100000` to `20261022160000`) | `sso_clients`, `sso_saml_clients`, `sso_assignments`, `sso_subjects` (random pairwise), `sso_disclosure_grants`, `sso_transactions`, `sso_signing_keys` (public only), `sso_audit_events`; service-only RPCs, replay-safe consume, `manage_sso_clients` permission | No OIDC client, code or token tables. One active key per client. Assignments are per user only |
| Issuance routes `apps/web/src/app/api/v1/sso/**` | SAML metadata, SSO Redirect/POST, decision endpoint, Redis rate limits, encrypted transaction cookie, session binding, MFA recheck after signing | One deployment-pinned client (`SSO_SAML_CLIENT_ID`) and one private key (`SSO_SAML_SIGNING_KEY`) in server env |
| Consent UI `/{locale}/sso/consent` | Sorbet consent and reauthenticate screens, EN/VI, a prompt on every login | No remembered consent and no app launcher |
| Admin UI `/{wsId}/sso` | Create (disabled), edit trust, enable/disable, MEMBER assignment, public key panel, 50 sanitized audit events | SAML only, with no OIDC, keyring rotation, group/role assignment or SCIM status |
| MFA | `checkRequiredAccountMfa`, factor-bound TOTP proof no older than 10 minutes, `mfa=totp` login hint | Freshness is fixed at 10 minutes |
| Feature flags | `SSO_SAML_ENABLED` server env, literal `true`; `config/feature-flag-catalog.json` lifecycle catalog | No catalog entry yet. No OIDC or SCIM flags |

Pilot status: no client has been enabled, the flag is off, and no real Claude or
WorkOS login has been run. Phase 5 of the existing page, which covers rotation,
operator custody and real acceptance, is still open.

### Verified claude.ai requirements (help center, read 2026-11-24)

* Claude uses **WorkOS** as its SSO broker. An Owner opens **Organization settings
  → Authentication → Setup SSO** and completes a WorkOS setup flow.
* Both **SAML** (X.509 signing certificate) and **OpenID Connect** (client secret)
  are supported, on Team, Enterprise and Console organizations.
* Domains must be verified with a DNS TXT record starting
  `anthropic-domain-verification-` at the exact domain. All domains of a parent
  organization must use one IdP.
* **SCIM is Enterprise only**, through WorkOS directory sync. Team plans get
  just-in-time (JIT) provisioning, and JIT never removes members.
* **Require SSO for Claude** makes every user on the domain use SSO. An expired
  certificate or secret then locks out everyone until Anthropic support helps.
  Deleting the connection signs out every user on the verified domains.
* IdP-initiated login is documented as unsupported for Console organizations.
  The help center does not state the exact WorkOS entity ID, ACS URL, NameID
  format or required attributes. Read them from the WorkOS setup flow at
  connection time.

Sources: support.claude.com articles 13132885 (set up SSO), 10276682
(considerations), 13133195 (JIT/SCIM) and 9797531 (Enterprise plan).

## Decisions proposed by this design

1. **SAML first, OIDC second.** Claude accepts both, but SAML is already built
   and reviewed through phase 4. The first live connection is Claude over SAML.
   OIDC follows for relying parties that support only OIDC, or that prefer it
   (for example Notion or custom internal tools).
2. **Issuance stays in `apps/web`** on the Next.js Node runtime, where the
   active runtime policy puts live API and page behavior. Protocol and policy
   logic stays in `packages/sso`, free of framework imports, so a later Worker
   port reuses it. Background work (SCIM push, key-expiry alerts, audit
   retention) goes to Cloudflare Workers, per the
   [background work inventory](https://docs.tuturuuu.com/build/devops/background-work-inventory.md).
3. **Private signing keys never live in the database**, and should not live in
   Vercel env either. Sign through a dedicated Cloudflare signer Worker that
   builds the assertion or token itself from structured, permit-checked input.
   It is never a raw signing oracle. A non-exportable KMS key behind the Worker
   is the stronger option. See [Key custody](#key-custody-and-rotation) and open
   decision D3.
4. **Eligibility is narrow by default.** Only current MEMBERs of the selected
   internal workspace can use SSO, with a confirmed email in an approved domain
   (initially `tuturuuu.com` only), current MFA, and an explicit assignment to
   that app. Role-derived grants are a later, constrained option (S3).
5. **No unsolicited (IdP-initiated) assertions by default.** The app launcher
   opens each SP's own SSO start URL (SP-initiated). Per-client IdP-initiated
   SAML is a later, explicit opt-in, and never for Claude.
6. **No single logout.** Tuturuuu logout does not end SP sessions. Deprovisioning
   uses SCIM where the SP supports it, plus short assertion lifetimes and
   assignment revocation.

## Eligibility and the application registry

An **application** is a row in `sso_clients` with a protocol profile (SAML today,
OIDC added). Each belongs to one active non-personal workspace. Its fields:

| Field | SAML | OIDC |
| - | - | - |
| Identity | SP entity ID | `client_id` (server-generated UUID) |
| Destinations | One to eight exact HTTPS ACS URLs | One to eight exact HTTPS redirect URIs, byte-equal. No loopback or native clients in the first release |
| Credentials | Optional pinned SP request-signing certificate | Confidential: hashed client secret or `private_key_jwt` JWKS (pinned, never fetched). Public: PKCE only |
| Claims | NameID (persistent pairwise) plus `email`, `firstName`, `lastName` | `sub` (pairwise) plus `email`, `email_verified`, `given_name`, `family_name` |
| Access | Explicitly assigned MEMBERs (role-derived grants only under the S3 constraints) | Same |
| Session | Assertion lifetime (default 2 minutes, maximum 5) | Code 60 seconds, id\_token 5 minutes, access token 10 minutes |
| State | Disabled at creation; enable is a separate, MFA-confirmed action | Same |

Login eligibility is checked at admission, at consent, at consume and again after
signing:

1. The Tuturuuu account is active, its email is confirmed, and the domain of the
   **fresh Auth email** (not the profile email) is in the client's approved
   domains. The initial internal allowlist is exactly `tuturuuu.com`. The domain
   must match exactly after lowercasing. Non-ASCII (IDN) domains are rejected,
   both in client domain lists and in Auth emails. Disabled or banned Auth
   accounts are denied.
2. The account is a current MEMBER of the client's workspace. Guests, invitees
   and domain matches alone are not enough.
3. The account has an active explicit assignment for the client. The binding
   rule in [Outbound SSO to Claude](https://docs.tuturuuu.com/platform/features/sso.md) still applies:
   rejoining or promotion needs a new assignment. Role-derived grants (S3) need
   all of the following, plus an explicit amendment of that page:
   * they apply only to roles whose membership changes themselves require
     `manage_sso_clients`;
   * consume and `sso_finalize_issuance` lock the role-membership rows, as they
     lock assignments today, with a pgTAP race for it;
   * every role-derived grant is audited.
4. The account's **factor-bound TOTP proof** is no older than the client's
   `mfa_max_age` (see D2). Age is measured from the proof time, never from the
   session's aal2 or a refresh `iat`. `mfa_max_age` defaults to 600 seconds.
   A manager with a current MFA proof can raise it to at most 12 hours. A
   client marked high-privilege (GitHub Enterprise, admin consoles) is capped at
   600 seconds by schema. `ForceAuthn` and OIDC `prompt=login` always require a
   fresh proof. OIDC `max_age` is checked against `auth_time` (primary sign-in)
   as well as the MFA proof age.

Per-workspace domains (for customers using Tuturuuu as their IdP) come later. A
domain is added only after Tuturuuu verifies it with its own DNS TXT challenge.
That lets a workspace approve a domain it controls, not one it only typed.

## Protocols

### SAML 2.0 (built; extended)

* **Endpoints**: `GET /api/v1/sso/saml/{clientId}/metadata`, and
  `GET|POST /api/v1/sso/saml/{clientId}/sso`. The issuer and entity ID are derived
  from `SSO_SAML_ORIGIN`, never from Host.
* **Change**: remove the single-client env pin. Each enabled client resolves its
  own profile, active key and request-signing policy from the database.
* **Change**: metadata publishes every key in `active` and `pending` states as
  separate `KeyDescriptor use="signing"` elements, so an SP that imports metadata
  trusts the new certificate before it is used.
* NameID stays `persistent`, carrying the random pairwise subject. Email goes
  only in the `email` attribute. Subjects are never derived from email, because
  addresses can be reassigned. Before enabling Claude, confirm in the WorkOS
  flow that a persistent NameID is accepted. If WorkOS requires an
  `emailAddress` NameID, enabling it needs a recorded exception. Under that
  exception, SSO is blocked after any email change until an operator reviews it
  (the existing rule), and deleted internal addresses are never reassigned.
* IdP-initiated (later, per-client opt-in): requires a registered default ACS and
  RelayState allowlist, a CSRF-protected POST started by a user action, admin
  MFA to enable it, no remembered consent, and a one-time server transaction,
  since there is no `InResponseTo`. It stays off for Claude.

### OpenID Connect provider (new)

* **Issuer**: `https://tuturuuu.com/api/v1/oidc` (decision D4). The issuer must
  never change once clients exist.
* **Discovery**: `{issuer}/.well-known/openid-configuration`. **JWKS**:
  `{issuer}/jwks`, which publishes `active` and `pending` keys.
* **Flow**: authorization code only. `response_type=code`, PKCE `S256` is
  mandatory for every client (including confidential ones), and `state` and
  `nonce` are required. Implicit, hybrid, `plain` PKCE, `request_uri` and dynamic
  client registration are not supported.
* **Authorize** `GET {issuer}/authorize`: the exact `redirect_uri` match (byte
  equal to a registered URI) is checked **before** any redirect. Errors with an
  unknown client or redirect render a local error page and never redirect.
  The same Sorbet consent page and transaction machinery as SAML apply. Every
  authorization response carries `iss` (RFC 9207) to stop mix-up attacks.
* **Token** `POST {issuer}/token`: `client_secret_basic` or `private_key_jwt`.
  A `private_key_jwt` assertion must use the pinned algorithm (never `none` or
  `HS*`). `iss` and `sub` must both equal the `client_id`. Its `aud` must be
  exactly the issuer or exactly the token endpoint URL, and an array carrying
  any other value is rejected. `exp` is at most 5 minutes out, and `jti` is
  required and single use per client (cached until expiry). Client secrets
  are 256-bit random values stored as SHA-256 hashes (high entropy needs no
  slow hash). Rotation allows two valid secrets during an overlap window.
  Codes are 256-bit random, stored hashed, single use, valid for 60 seconds and
  bound to client, redirect URI, PKCE challenge, nonce, account, session,
  policy revision, granted scopes and claims hash. Access tokens carry the same
  scopes and claims hash. Reusing a code burns it and revokes every token
  issued from it.
* **Tokens**: the id\_token is RS256-signed, valid 5 minutes, with claims `iss`,
  `sub` (pairwise per client), `aud`, `azp`, `exp`, `iat`, `auth_time`, `nonce`,
  `acr` (`urn:tuturuuu:aal2`), `amr` (the methods actually used, such as `pwd`
  or `otp`, never a fixed value; other factors count only once a later decision
  qualifies them for the MFA rule), and with consent `email`,
  `email_verified`, `given_name`, `family_name`. The access token is opaque,
  hashed at rest, valid 10 minutes, and grants only `userinfo`. **There are no
  refresh tokens** in the first OIDC release.
* **UserInfo** `GET {issuer}/userinfo`: only the claims the token's scopes
  granted. It rechecks the account, membership, assignment and token
  revocation, but not MFA age, which applied at authorization.
* **`prompt`**: `login` forces a fresh sign-in plus MFA. `consent` bypasses a
  remembered grant. `none` returns `login_required`, `interaction_required` or
  `consent_required` instead of showing any page.
* **Scopes**: `openid` (required), `email`, `profile`. Unknown scopes are rejected.
* OIDC signing keys are never shared with SAML. Each `kid` is bound to one client
  and one protocol.
* These OIDC keys, codes and tokens are separate from the external-app bearer
  and cross-app token systems, and never reuse their signing keys.

## Security model

| Threat | Control |
| - | - |
| Signing-key theft | Keys live only in the signer Worker (or KMS behind it). The Worker builds what it signs from structured input and a database-signed permit. Database and UI hold public certificates only. See the compromise runbook below |
| Assertion or code replay | Unique request ID per client (`sso_transactions`), single-use consume under row locks, `InResponseTo` binding, 2-minute assertions, 60-second codes |
| Open redirect or ACS injection | Exact string match against registered ACS/redirect URIs. HTTPS only, with no wildcards, credentials, fragments or custom ports. Errors before validation never redirect. RelayState is length-bounded and returned opaque |
| Signature wrapping or XML attacks | Covered in phase 1: DTD rejection, bounded inflate, unique IDs, and `getSignedReferences()` after verification |
| Session fixation or account switch | The transaction is bound to the starting account and session hash. An account switch burns it |
| Stale privilege | Membership, assignment, role, domain and MFA age are rechecked at consume and after signing. Revocation applies to the next login |
| Phishing-style consent | The consent page names the app, its registered domain and the exact claims, and is never framed (`frame-ancestors 'none'`) |
| Brute force or abuse | Existing fail-closed Redis limits. OIDC adds limits for token (60/min per client), authorize (20/min per IP), userinfo (60/min per token) and failed client authentication (10/min per client plus IP, then exponential backoff, never a hard per-client lockout, since `client_id` is public) |
| Insider misconfiguration | `manage_sso_clients` permission, an MFA proof under 10 minutes for every trust write, revisioned updates, and creation disabled |
| Audit tampering | Append-only `sso_audit_events` with no email, assertion or token material, only event codes and UUID correlation |

### Key custody and rotation

* Each key has a `kid`, a status from the existing schema (`pending` → `active`
  → `retiring` → `revoked`) and validity dates. At most one key is `active` per
  client, enforced by a partial unique index. Each `kid` is bound to exactly one
  client and one protocol. RSA keys are never shared between SAML and OIDC.
* **Custody**: private keys are Worker secrets named `SSO_SIGNING_KEY_<KID>` on a
  dedicated signer Worker, or non-exportable KMS keys the Worker calls (D3).
  The Worker is **not** a raw signing oracle:

  * `apps/web` sends structured input: client, protocol, transaction, subject,
    the consented attribute values (`email`, `firstName`, `lastName`), audience
    or ACS, `NotOnOrAfter` or `exp`, and nonce or `InResponseTo`.
  * The Worker builds the assertion or JWS itself, through the same
    `packages/sso` builder and canonicalizer, and signs both the SAML
    `Response` and `Assertion`.
  * It accepts a request only with a finalization permit issued at
    `sso_finalize_issuance`. The permit binds a hash of every structured field
    plus the `kid`, lives 60 seconds or less, and is single use.
  * Permit IDs and request nonces are recorded in a Durable Object
    (strongly consistent), never in KV or isolate memory, so a replay to
    another isolate or region is still refused.
  * The Worker also confirms the transaction independently, through a
    dedicated Worker-only database role that can read only an approved,
    consumed, not-yet-signed transaction and its bound fields. A compromised
    `apps/web` holds the HMAC and permit keys, but still cannot mint an
    assertion for a subject, client or destination with no real consumed
    transaction. Without that check the Worker would only protect the
    private key from extraction.
  * The permit is signed with a dedicated Ed25519 key. The service-only
    finalization path signs it with a secret held outside Postgres (a server
    secret, never a database column or setting). The Worker holds only the
    public key and checks it. That key rotates on the same dual-publish
    schedule as signing keys.
  * It checks the `kid`-to-client and `kid`-to-protocol binding.
  * Requests are authenticated by an HMAC over the body plus a timestamp and a
    single-use nonce, never a static bearer.
  * It rate-caps issuance and logs a correlation ID only.
  * `issuance.signed` is appended only after the Worker returns a signature.
    A Worker timeout or error appends `issuance.failed` and burns the
    transaction. The existing five-second budget covers finalization, the
    Worker call and the final MFA recheck together, so the 60-second permit
    lifetime never extends it. This amends the finalization order in
    [Outbound SSO to Claude](https://docs.tuturuuu.com/platform/features/sso.md) once S1c ships.
  * Deploying it and writing its secrets is restricted to the release authority
    in Cloudflare.

  S1 changes the synchronous `SamlSigner` contract (`({xml,id,kind}) => string`
  in `packages/sso/src/contracts.ts`) into an async signer port, and spikes
  assertion construction inside the Worker. Changing `node-signer.ts` alone is
  not enough.
* **Rotation (SAML dual-publish)**: create a `pending` key and publish it in
  metadata alongside `active`. The admin re-imports the metadata or uploads the
  new certificate in WorkOS. After the SP confirms, promote `pending` to
  `active` and demote the old key to `retiring`. A retiring key stays in
  metadata for about one day (enough for in-flight assertions), then becomes
  `revoked`. Claude's portal accepts one certificate at a time, so **rotate
  only with Require SSO off**. Alert 30 days and 7 days before expiry from a
  Cloudflare cron. Certificate validity is 2 years (D5).
* **Rotation (OIDC)**: publish the `pending` key in JWKS at least 24 hours before
  promotion. RPs cache JWKS, so promote in the same staged order.
* **Compromise**: a stolen key can mint assertions for **any** email, including
  Claude Owners, with any lifetime, until the SP stops trusting it. Turning off
  issuance on the Tuturuuu side does not help. The runbook, rehearsed before
  the pilot:

  1. Turn Require SSO off, or confirm the verified Owner bypass works.
  2. Replace or remove the certificate in WorkOS.
  3. Set the key to `revoked` and disable issuance.
  4. Rotate the key.
  5. Re-establish trust.

  The exposure window lasts until SP trust changes.
* **Availability**: monitor the signer Worker and the Redis limiter. Both fail
  closed, so an outage denies every SSO login. That is acceptable only while
  Require SSO is off, or while an Owner bypass has been verified (see rollout).

### Audit

Each admission, consent, denial, consume, signature, failure, OIDC code exchange
and userinfo read appends one event: type, client, policy revision, `kid`,
correlation and transaction UUIDs, and time. No email, names, tokens, assertions
or IP addresses are stored in audit rows. A security review can map the actor
UUID to an email through access-controlled tables. This is stricter than "email
only" on purpose. New event types (key promotion and revocation, role-derived
grant, remembered-consent use and revocation, SCIM connection changes and
dead-lettered SCIM operations) extend the `event_type` check list by migration.
Retention (D7) runs from the existing Cron Control Worker through a dedicated
service-only, time-bounded purge function, never by disabling or bypassing the
append-only triggers. Designing that function is part of its slice.

## SCIM provisioning (phase 2 of this design)

* Tuturuuu acts as the **SCIM client**. It pushes users to each SP's SCIM 2.0
  endpoint, for example Claude Enterprise through WorkOS directory sync.
* Triggers: assignment granted or revoked, role change, membership removal,
  demotion to guest, account deletion, Auth ban or disable, name change and a
  change of email or email domain. These fire only for users who are assigned
  to, or already SCIM-linked with, that client, so changes to other workspace
  members never touch existing SP accounts. Each writes an outbox row in the
  same transaction. The row holds only IDs (no PII).
* Each linked user has a stored `(client_id, user_id) → scim_remote_id`
  mapping, created from the SP's response to the first create. Updates and
  deactivation address that ID only, and never match accounts by email. That
  way an email change cannot relink another existing account, including a
  Claude Owner.
* A Cloudflare Queue consumer delivers the user's **current state**, computed
  when the call is sent and ordered by a per-user sequence number, not raw
  events. A reordered event therefore cannot re-activate a revoked user.
  Operations are idempotent `PUT` or `PATCH active=false` calls.
* Stop fence: both the `sso_scim_push` flag and
  `sso_scim_connections.enabled` are checked before **every** HTTP call.
* Retries are bounded (5, exponential) behind a per-client circuit breaker.
  After the limit, an operation goes to a dead-letter queue, and an alert fires
  for any missed deprovision.
* Endpoints must be HTTPS on an allowlisted host. Private and internal addresses
  are refused. Requests use `redirect: 'manual'`, and any 3xx is treated as a
  failure, so the bearer token is never forwarded to another origin.
* Cost bounds follow the Cloudflare billing rules in AGENTS.md: bounded work per
  invocation, terminal-state scheduling, and operation-count tests.
* Bearer tokens are Worker secrets by name, written only by the release
  authority. The admin UI shows connection health and never accepts a token.
* Deprovisioning sends `active=false`. Hard delete only follows an explicit
  admin policy.
* Team-plan Claude has no SCIM. There, deprovisioning means revoking the
  assignment (so SSO is denied on the next login), plus removing the user
  manually in Claude. With Require SSO on, the existing Claude session ends at
  its own expiry.

## User experience

All strings are in EN and VI. The UI uses `@tuturuuu/ui` Sorbet components only,
with mockups made in Claude Design and Artifacts and reviewed with the
design-system lead before the UI slices.

* **Sign in with Tuturuuu** (exists; extended): the app's name and icon, its
  registered domain, the claims list, and Allow/Deny. With D1 "remember", later
  logins skip the prompt and show a short "Signing you in to {app}"
  interstitial. That flow works like this:

  * the interstitial does not auto-submit. The user selects **Continue**, a
    same-origin, CSRF-protected POST bound to the session, before any
    assertion or code is released. A cross-site page that starts SP-initiated
    SSO therefore cannot complete a login silently;
  * the server approves the transaction and still writes the per-login
    disclosure receipt;
  * the remembered grant is keyed on actor, client, policy revision and a hash
    of the claim names and their current values, so a changed email or name
    asks again;
  * users can revoke it;
  * `ForceAuthn`, OIDC `prompt=consent` and `prompt=login` bypass it;
  * it never applies to IdP-initiated logins.

  D1 and D2 amend the every-login consent rule and the fixed ten-minute MFA
  rule in [Outbound SSO to Claude](https://docs.tuturuuu.com/platform/features/sso.md). That page is
  updated in S3, when they ship.
* **My apps launcher** (new) at `/{locale}/apps`: the tiles the user is assigned
  to. Each tile goes to the SP's registered SSO start URL, so the SP initiates.
* **Admin applications** (exists at `/{wsId}/sso`; extended): a protocol picker
  (SAML or OIDC), templates (Claude, GitHub Enterprise, Slack, Notion) that
  pre-fill only non-secret defaults, role-based access, a keyring panel with
  "publish pending key" and "promote", an OIDC client secret shown once, SCIM
  connection health, and the audit list.

## Feature flags and rollout

| Flag | Kind | Default |
| - | - | - |
| `SSO_SAML_ENABLED` (exists) | kill-switch | off everywhere |
| `sso_oidc_provider` | release | off everywhere |
| `sso_scim_push` | release | off everywhere |
| `sso_app_launcher` | release | off everywhere |

Add every flag to `config/feature-flag-catalog.json`. The per-client `enabled`
column is a second independent gate.

Rollout: staging with a local SP and RP first. No separate Claude test
organization exists, so the pilot runs on the production Tuturuuu Claude
organization (Enterprise, with SCIM). That makes these pilot rules binding:

1. **Require SSO stays off for the entire pilot.** SSO is optional. Require SSO
   can be considered only after at least two Claude admins have signed in
   through SSO, and email-link login has been confirmed to work as break-glass.
2. **Break-glass owner.** A documented Claude Owner account that is not bound
   to SSO, signs in by email link, and is never assigned to the Tuturuuu SSO
   application. Prefer an address on a domain that is not verified for SSO, if
   Claude allows such an Owner, so that a later Require SSO cannot bind it.
   Record its existence (not its credentials) in the pilot packet. During S2
   setup, confirm and record Claude's JIT setting (kept off).
3. **Named pilot users first.** Assign only one or two named `@tuturuuu.com`
   pilot users. Widen to the rest of the organization only after their logins,
   denials and revocations behave as specified. SCIM starts in dry-run (compute
   and audit the operations without sending them), then runs against those
   pilot users only.
4. **Rotation before expiry risk.** Rehearse dual-publish rotation (publish the
   pending key, update WorkOS, promote, retire) on the live connection while
   Require SSO is off, long before the first certificate nears expiry.
5. **Domain verification.** The Claude Owner starts verification of
   `tuturuuu.com` in Claude to obtain the exact TXT value. The release
   authority then adds the record in Cloudflare DNS. The pilot packet records
   the exact record (name `tuturuuu.com`, type `TXT`, the full
   `anthropic-domain-verification-…` value, and TTL) before it is created.

The kill switch (flag off plus client disable) is a safe rollback **only while
Require SSO is off**. Users then sign in to Claude by email link. With Require
SSO on, the kill switch, a signer or limiter outage, or a certificate-swap gap
locks out the whole organization. Claude's help center says recovery then
needs Anthropic support. Before Require SSO is turned on:

* confirm in Claude, with recorded evidence, that an Owner can bypass SSO;
* set the runbook order to "turn Require SSO off first, then the kill switch";
* do every rotation with Require SSO off.

## Delivery slices

Each slice gets tests, a cross-family security review and a `check:changed`
pass, and lands separately. Migrations need an isolated reset plus a pgTAP
receipt and an exact-SQL ACK.

1. **S1 Multi-client and keyring (SAML)**: drop the env client pin, publish
   `pending` and `active` keys in metadata, add the async signer port, and build the
   Worker spike. Migration.
2. **S2 Claude pilot**: catalog flag, operator runbook, staging acceptance
   against the local Node-SAML SP, then the real Claude test connection (needs
   USER actions and an Iris ACK).
3. **S3 Remembered consent, per-client MFA age and constrained role grants**
   (D1, D2). Migration.
4. **S4 OIDC provider core**: tables, discovery, JWKS, authorize, token and
   userinfo, behind `sso_oidc_provider`. Migration.
5. **S5 Admin UI for OIDC and keyring, plus the app launcher.**
6. **S6 SCIM push Worker** behind `sso_scim_push`. Migration.
7. **S7 Per-workspace verified domains** for customer IdP use.

## Test plan

* **Unit** (`packages/sso`): OIDC request validation (redirect mismatch, missing
  PKCE, `plain` PKCE, missing nonce, unknown scope), id\_token claims and
  expiry, multi-key metadata and JWKS, the `kid` selection state machine, and
  remote-signer error handling (timeout, wrong `kid`, malformed signature).
* **Route** (`apps/web`): the real handlers with mocked Auth/RPC. They cover
  ineligible domain, guest, unassigned, role-removed, stale MFA, account
  switch, replayed code or assertion, disabled client and limiter outage.
* **pgTAP** (`sso-persistence.sql` plus new OIDC/SCIM fixtures): code
  single-use races, the token revocation cascade, role-grant re-evaluation,
  outbox atomicity, and append-only audit.
* **End to end** in an isolated environment: the Node-SAML SP harness and an
  `openid-client` RP harness log in with a seeded MFA user. Add a SCIM mock
  server for idempotency and stop-fence tests.
* **Acceptance**: the real Claude connection test, Test SSO in WorkOS, denial
  cases, and a rotation rehearsal on the test connection.

## Connecting claude.ai (USER, as Claude organization Owner)

1. In Claude, open **Organization settings → Organization and access → Add or
   edit domains** and add `tuturuuu.com`. Copy the `anthropic-domain-verification-…`
   value into the pilot packet. The release authority creates that TXT record at
   the apex domain in Cloudflare DNS. Wait for **Verified**.
2. In Tuturuuu, open the internal workspace's **Single sign-on** page, then
   **Add SSO application → Claude**. Leave it disabled for now.
3. In Claude, go to **Authentication → Setup SSO**, choose **Custom SAML**, and
   copy the WorkOS **ACS URL** and **SP Entity ID** into the Tuturuuu
   application. Note the WorkOS NameID and attribute requirements.
4. Copy the Tuturuuu **metadata URL** (or the IdP entity ID, SSO URL and public
   certificate) into WorkOS. Map `email`, `firstName`, `lastName` and `id`.
5. In Tuturuuu, assign only the one or two named pilot users. After the release
   authority approves the exact configuration, enable the application and run
   **Test SSO** in WorkOS.
6. Keep **Require SSO for Claude off** and **JIT off** (members stay invited)
   for the whole pilot. Confirm the break-glass Owner still signs in by email
   link. Widen assignments only under the pilot rules above.
7. Connect SCIM after S6 ships, in dry-run first. Register the WorkOS
   directory-sync endpoint host in the Tuturuuu SCIM connection. The release
   authority stores the WorkOS bearer token as a Worker secret. The token is
   never pasted into the Tuturuuu UI.

## Decisions (2026-11-24)

* **D1 Consent**: remembered per app, keyed on actor, client, claims hash and
  policy revision. Users can revoke it in account settings. Every login still
  writes a disclosure receipt.
* **D2 MFA freshness**: at most 12 hours from the last factor-bound TOTP proof
  for ordinary apps, and 10 minutes for high-privilege apps.
* **D3 Key custody**: an assertion-building Cloudflare signer Worker that holds
  keys as Worker secrets by name. Non-exportable KMS stays a later hardening
  option.
* **D4 OIDC issuer** (default): `https://tuturuuu.com/api/v1/oidc`.
* **D5 Certificate lifetime** (default): 2 years, with dual-publish rotation.
* **D6 Claude plan**: Enterprise, with SCIM through WorkOS directory sync.
* **D7 Audit retention** (default): 1 year.
* **D8 Internal workspace** (default): the root workspace owns the internal
  applications.

No separate Claude test organization exists, so the pilot runs on the
production organization under the pilot rules in
[Feature flags and rollout](#feature-flags-and-rollout). Claude domain
verification of `tuturuuu.com` is still open.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.