Identity plane split, plan I3g: the switch (epic &133)

Status: Done (2026-10-12) — !1596
Epic: &133 (stage I3 of &130)
Issues: #2864 (U1, w3); #2865 (U2, w5); #2866 (U3, w5); #2867 (U4, w8); #2868 (U5, w3); #2869 (U6, w8); #2870 (U7, w8); #2871 (U8, w3); #2872 (U9, w8); #2873 (U10, w5); #2874 (U11, w5); #2875 (U12, w3); #2876 (U13, w3); #2877 (U14, w5); #2878 (U15, w5); #2879 (U16, w8); #2880 (U17, w8); #2881 (U18, w8); #2882 (U19, w8); #2883 (U20, w5); the external review #2884 (a deployment gate, R24).
MR: feat/identity-switch, "the switch (#2864 … #2883)", one commit per issue (K1); the branch stays local until green (R26).

This is a Design + Scope plan, over the ~300-line cap by the maintainer’s ruling (R25). GitLab owns tracking, and the plan freezes when U1 starts. SW1–SW16 are this plan’s decisions (ADR-049 Amendment 25); R24–R26 are the maintainer’s rulings.

Each issue carries priority::high, program::infrastructure, workflow::ready and planning::has-plan, plus the one type:: and one service:: its unit names.

Context

I3g is the cut-over itself (ADR-049 Amendment 11). Stages I3a–I3f landed every canopy-identity piece as library code or devstack infrastructure, unwired (K1).

The switch is one MR, because no state in between is coherent:

  • canopy-web can’t hold a canopy-identity session and a Keycloak token at once;

  • a receiver flipped alone is refused by every peer;

  • dual trust would be a shim.

What the switch does:

  • wires every receiver and sender;

  • moves canopy-web, the portal, canopy-cli and the operator tools onto their clients;

  • moves the battery onto the token broker;

  • deletes the Keycloak path;

  • settles #2649, #1869, #1901, #1595 and #1447.

Size (2026-10-11).

Area Count

Handler Extension<Claims> sites

~374

delegated_routes() rows

120

Service sender sites

~110

canopy-web reads on its service token

74

canopy-web exchanged calls

37

Portal token sites

22

canopy-cli token consumers

44

Rust test files on Keycloak tokens

138, ~540 calls

Playwright files on Keycloak tokens

35, ~116 calls

Playwright storage states / projects fed

9 / 31

k6 profiles on Keycloak tokens

4

  • Deleted: about 15k lines of legacy canopy-auth, canopy-web’s 11k-line auth/ tree, about 3k lines of xtask, and the 1.9k-line realm.

  • New product surface: the AC-8 sign-in page, the security-admin pages, the device-approval pages, and canopy-web’s https origin. None exists today.

The maintainer’s rulings (2026-10-11):

  • R24. The merge gate moves to deployment. The switch merges to main once green. The external security review (ADR-049 Consequences) and the issuance log’s retention (#1303, deployment guide › Prerequisites) gate a production deployment, not main. This amends K1’s merge clause, T5 and the Consequences bullet. U1 files an issue tracking the review.

  • R25. One plan, over the cap.

  • R26. A local branch with bundle backups. Every push runs the full battery, and no intermediate state can pass it. So feat/identity-switch stays local until green, with a bundle after each unit, then one push.

Decisions (ADR-049 Amendment 25, SW1–SW16; land with U1)

SW1. Staging and compilation (R24, R26)

Each unit:

  • is one signed commit on feat/identity-switch, through the pre-commit review;

  • leaves cargo check --workspace --all-targets --features canopy-portal/server,canopy-portal/preview passing;

  • ports every compile site its change breaks, tests included. U16–U18 own only the runtime token sites;

  • deletes what its change leaves unreferenced (dead-code warnings may span units, as in I3f1). U19 deletes what remains (SW13);

  • is followed by git bundle create ~/backups/canopy-switch/NN-<slug>.bundle main..HEAD.

Integration may be red between units. The branch rebases onto main before its one push. It merges once the pre-push battery passes (the standing rule).

The Keycloak pieces stay until U19. The bootstrap keeps building them for consumers not yet moved:

  • BootstrapResult.auth, oidc_discovery, service_token_source;

  • the nine ServiceSettings fields.

ApiServer installs only the identity layer from U4 on.

SW2. The devstack’s staged bring-up (K2, K4, K8)

canopy-web needs canopy-web’s Kanidm client secret at boot, and Kanidm mints it only when its migration creates the client (cast::provision, on an absent, unreadable, drifted or emptied cast). So every bring-up path stages Kanidm before the stack:

  • do_start (dev start, reload, restart);

  • the guard’s cold start, prebuilt included;

  • auto_refresh whenever it runs an up.

The stages:

  1. before_up: files and the TLS pair, as today, plus the ingress leaf (SW6).

  2. The new devstack_identity::kanidm_phase:

    • up -d --no-deps --wait kanidm (--no-build on the prebuilt path);

    • cast::ensure, moved here from after_up;

    • read .devstack/idp/kanidm.json's client secret into the up env as CANOPY_WEB__UPSTREAM_CLIENT_SECRET, beside SW4’s keys.

  3. The stack’s up and health wait.

  4. after_up:

    • restart_readers, whose TLS_READERS gains canopy-web, canopy-web-xsite (when running) and both ingresses;

    • settle_profile, which on a Kanidm port move restarts canopy-web and canopy-web-xsite beside canopy-security;

    • link_cast.

A re-provisioned cast’s new secret reaches canopy-web because its env changes and the stack’s up recreates it. Tests pin each path’s order: the Kanidm phase precedes the stack’s up, and the secret is in that up's env.

SW3. The bootstrap (L6, E2, E4)

Settings.

  • ServiceSettings gains the required identity_issuer and identity_internal_url. The bootstrap is their first reader (L6).

  • canopy-security’s MIRRORED_KEYS gains both, so its SecurityConfig still reads them. Unmirrored, its issuer would silently disable. the_identity_issuer_pair_loads_from_its_env_names changes accordingly.

Reserved keys. Each service holding a client key adds IDENTITY_CLIENT_PRIVATE_KEY to its own RESERVED_KEYS, creating the list where absent. canopy-web also adds UPSTREAM_CLIENT_SECRET. Each service’s config test loads with the injected key set and checks reserved_keys_are_not_fields.

Receivers (service_name.parse::<CanopyService>()):

Service Receiver

canopy-security

The bootstrap builds none. Its main builds IdentityReceiver::new(IdentityTokenValidator::new(issuer, Security, MemoKeySource)) and installs it on the /v1 it assembles

Any other CanopyService

IdentityReceiver::over_http(&settings, service, http)

canopy-web, canopy-exchange

None. ApiServer mounts /v1 only behind a receiver, so a route added to exchange answers 404 until exchange becomes a receiver. canopy-web’s pages take its session

AppState becomes { db, receiver: Option<IdentityReceiver> }.

  • The eight mains that attach the applicant verifier now attach it to boot.receiver (same loader, same trait object).

  • U4 ports every AppState construction (grep -rn 'AppState {', about 20).

  • Offline test states take canopy_test_lib::identity::offline_receiver(service), an empty key set that refuses every token. States serving real tokens take devstack_receiver(service).

Senders (service_name.parse::<ConfidentialClient>() where client.service().is_some(), 13 services):

  • IdentitySender::from_secrets(&settings, client, &EnvSecretProvider::new(service_name), http), held as Arc<IdentitySender> in BootstrapResult.sender and as an extension.

  • canopy-web and the portal build their own senders (SW9, SW12). persons, rules and security send nothing.

Boot order. Every service’s depends_on names canopy-security: service_healthy.

SW4. Admission

Each handler extracts Extension<Principal> (and Option<Extension<ApplicantOwnership>> where it checks ownership) and calls principal.admit(&ADMISSION)?:

  • A listed route uses its row’s constant. U5 promotes each of the 120 DELEGATED_ROUTES rows to a named pub const in canopy_auth::delegated (<SERVICE>_<METHOD>_<PATH WORDS>, e.g. PERSONS_GET_PERSONS_ID_ASSETS), and the table is built from them. No new gate.

  • An unlisted route follows I3c’s translation table (plans/archive/identity-plane-split-i3c.adoc, "Translating today’s bars"), with one precondition:

    • A service-only bar translates to Admission::system() only when a client other than canopy-web or the portal holds a System or Both edge to the service.

    • Where none does (appeals, notices, reporting, wic), the route’s admission follows R6’s effect rule for canopy-cli’s operators: Admission::user_roles_via(&[CLI], …), with reads CASEWORKER_OR_ABOVE_ROLES, writes the writer bar, destructive calls supervisor and admin, and operations admin. Its tests reach it through tokens::cli (SW13).

    • Notices' POST /v1/notices, POST /v1/notices/{id}/resend and GET /v1/notices/queue are the known cases: callerless in production, operations and a read. U6 and U7 list every case they find.

Ported helpers:

Today Becomes

EffectiveUser::actor() / .attribution_sub()

principal.actor()? / principal.attribution_sub()

CallerContext

Principal plus a BearerSource (SW5)

claims.sub

attribution_sub() or user()

service_id() == X

system_from(&[X]), or principal.client() == Client::Confidential(X)

require_owned_*(&claims, …)

principal.require_owned_*(…)

WIC’s Actor::Human { subject }

principal.user().map(UserPrincipal::oidc_subject)

effective_user.rs and caller_context.rs go with their last callers.

Attribution. A system caller’s attribution becomes its client id (A4): FTI accessed_by, redaction actor_sub, idempotency keys, bulk runs and export events. Every such column is TEXT, and nothing reads rows back by the old service-account subject (the realm randomized it per import).

SW5. Senders, sharing and the 401 retry (E5–E8)

BearerSource is a new canopy-auth trait whose methods take &self:

  • async fn bearer(&self, target: CanopyService) → Result<OwnedBearer, BearerError>;

  • async fn rejected(&self, target: CanopyService), async because SharedOutbound takes its lock to drop the tokens.

It is implemented by:

  • SharedOutbound<'s, 'p>, a tokio::sync::Mutex<Outbound<'s, 'p>>. bearer locks, mints, takes .owned() and unlocks, so a request’s concurrent calls (joined futures) share one delegation cache;

  • WebOutbound, held per request as Arc<WebOutbound>, which already shares one cache and one renewal across concurrent callers;

  • PortalSender;

  • ServiceTokenSource, which ignores the target. It lets unmoved callers compile, and it goes with the type in U19.

canopy_auth::send_with_retry(source, target, deadline: Option<Instant>, build), where build: Fn(&str) → reqwest::RequestBuilder. It generalizes AdminClient::exchange's loop and keeps its semantics:

  • each attempt is bounded by the remaining deadline;

  • a 401 naming insufficient_user_authentication (challenge or body, RFC 9470) is returned at once for the caller to classify, because a re-mint cannot refresh auth_time;

  • any other 401 calls rejected(target) and is sent once more, only while at least 1 s remains (RETRY_FLOOR);

  • a second 401 is returned.

AdminClient moves onto it, keeping StepUpRequired and its refusal mapping. Every outbound call site uses it.

Concurrency. A request’s concurrent calls run as joined futures over one SharedOutbound or Arc<WebOutbound>. Work that outlives its request is system-origin (E5) and builds its own Outbound from the Arc<IdentitySender>.

Shared clients.

  • PersonsClient holds an Arc<dyn BearerSource> in place of its ServiceTokenSource: persons.system() calls with that source (the service’s own, system origin) and persons.on(&source) with a request’s. Both return a PersonsCalls view whose methods call through send_with_retry.

  • RulesClient methods take source: &dyn BearerSource in place of token: Option<&str> (so rules_client_has_no_shared_token_state still holds), each call and its retry within RULES_CALL_TIMEOUT. CallerContext carries that source in place of its bearer_token.

  • A 401 is no longer a generic error.

  • U4 ports every caller to pass its current source (ServiceTokenSource; tests a FixedBearer), and U6, U7 and U9 swap the source.

  • signing_registration takes the Arc<IdentitySender> and sends through it as a BearerSource, which asks for a system token per attempt (every program’s edge to canopy-security is System). An acquisition the issuer answers unavailable (503 temporarily_unavailable, the first key’s 60 s lead) is retried within a 120 s budget without spending one of its six attempts. Its five mains move in U4.

Origins.

  • In-request: SharedOutbound::new(sender.calls(Origin::of(&principal))).

  • Background tasks, durable retries and boot: Origin::System.

Eligibility. Its hop two and fan-out are onward delegation (G9). TokenExchanger, ExchangePurpose::OrchestratorFanout, the exchanger client and EXCHANGE_TARGETS go.

Verification (E8, #2648). The four /internal/v1/ routes go behind the receiver at their own paths:

  • SOLQ uses its constant;

  • IEVS uses system_from(&[Snap]);

  • SAVE uses system_from(&[Eligibility, Snap]).

eligibility, snap and web send bearers, and CANOPY_INTERNAL_API_KEY and api/service_key.rs go.

Keys in the devstack (K4, E3).

  • The Kanidm phase (SW2) writes .devstack/identity/env/<client>.env (owner-only) for each confidential client: client_key_secret(client) with its key from .devstack/identity/keys/<client>.pem, and in canopy-web’s also CANOPY_WEB__UPSTREAM_CLIENT_SECRET.

  • Each of the 15 client blocks, and canopy-web-xsite, names its file as an env_file with required: false, so every compose invocation, a run that starts dependencies included, computes the same environment.

  • A service started before the files exist boots without its key and refuses to start (E3: no file fallback). That is loud.

SW6. canopy-web’s origin, the ingress and the issuer (Q1, J1; amends Q1’s proxy clause)

The ingress. Two devstack services run the upstream image directly, so no build is needed and the prebuilt path pulls it: nginxinc/nginx-unprivileged:1.31.6-alpine3.24-slim@sha256:<digest pinned at U2>, non-root (uid 101).

Service Profiles Alias Port Proxies to

ingress

every

web.canopy.test

its own allocated, same-port

canopy-web:8080

ingress-xsite

every

web.canopy-xsite.test, moved from canopy-web-xsite in U9

its own allocated, same-port

canopy-web-xsite:8080

  • One service per origin keeps SAME_PORT_SERVICES one port per service, and nginx never needs an absent upstream.

  • Config and leaf: an envsubst template (INGRESS_SERVER_NAME, INGRESS_PORT, INGRESS_UPSTREAM) and the leaf are installed by xtask into the canopy_ingress volume, read-only, by a one-off as devstack_tls::install fills Kanidm’s. CI’s daemon sees no job files, so there is no bind mount. The template:

    • terminates TLS;

    • sets X-Forwarded-For $remote_addr (overwrite, never append), X-Forwarded-Proto https and Host;

    • serves a plain 127.0.0.1:8081/healthz for compose’s healthcheck (wget -q -O /dev/null).

  • Why nginx-unprivileged (judgment-protocols comparison, 2026-10-11):

    Candidate Verdict

    Caddy 2.11.7-alpine

    Runs as root by default, and its proxy manages X-Forwarded-For itself

    HAProxy 3.2.25-alpine (LTS)

    Equal fit, but a heavier config for two names

    Traefik

    Ships no Alpine image

    An in-repo Rust proxy

    Code to own and test

    nginx is non-root, Alpine and BSD-2. It overwrites with one line, and is the commonest production ingress.

The leaf. devstack_tls::generate signs a second leaf (SANs web.canopy.test, web.canopy-xsite.test) in the same pass as Kanidm’s, since the CA key is never kept. current() checks every pair, and any miss regenerates all of them (SW2 restarts the readers).

Origins.

Kanidm. The Kanidm phase (SW2) sets the canopy-web client’s origin to canopy-web’s public origin and its redirects to both origins' callbacks, on every bring-up. That replaces the migration’s portless entry and registers the cross-site redirect.

Test inputs.

Input Value

CANOPY_TESTWEB_ORIGIN, CANOPY_TESTXSITE_ORIGIN

Set in HOST_BROKER_ENV and in compose for canopy-integration, canopy-e2e and canopy-token-broker

CANOPY_TESTWEB_ADDR, and the existing CANOPY_TESTKANIDM_ADDR

Rendered in .ports.env with docker::published_host(), not loopback, so CI’s Docker-in-Docker host lanes reach the daemon’s publications

The broker’s Upstream

Carries redirect_uris (both registered callbacks), replacing kanidm::REDIRECT_URI

routeUpstreamSignIn

Accepts any registered redirect and builds the callback from the request’s own redirect_uri

CANOPY_E2E_BASE_URL, CANOPY_E2E_XSITE_BASE_URL

The https origins

TestConfig.web_url

The https origin

Host Rust tests reach canopy-web through canopy_test_lib::web_client(), which pins web.canopy.test to CANOPY_TESTWEB_ADDR and trusts the devstack CA. Kanidm’s Credentials::http_client() pins to CANOPY_TESTKANIDM_ADDR the same way.

Port moves. canopy-security binds no session to its own issuer, so a resample or a port recovery that moves canopy-ingress moves the issuer without ending sessions:

  • every service is recreated with the new env, and Kanidm is re-provisioned;

  • a token minted under the old iss is refused token_rejected, and the sender’s retry re-mints under the new one;

  • onward delegations and native proofs naming the old endpoint fail once and are re-minted;

  • canopy-cli’s stored session names its issuer (O4), so token answers LoginRequired and the worker runs canopy login again;

  • a Kanidm port move ends web sessions at their next renewal (upstream_changed), as today.

Trusted proxies. The devstack sets no CANOPY_TRUSTED_PROXIES. Compose addresses are dynamic, entries are exact (Q2; CIDR is #2846), and every devstack client shares one address. The deployment guide states the production chain: the ingress overwrites; canopy-web trusts the ingress; canopy-security trusts canopy-web.

A host browser needs 127.0.0.1 web.canopy.test web.canopy-xsite.test idm.canopy.test and the devstack CA (.devstack/idp/kanidm-ca.pem) trusted. cargo xtask dev start prints both, and local-dev documents them.

SW7. Audit through canopy-identity (#2649, #1869)

  • The exchange audit goes: ChainAuditSink, TokenExchanger, and the ingest’s auth.token_exchange arm (validate_token_exchange_purpose, its dedup key, its action mapping). The issuance log is the audit-before-release (A6, §13). Historical chain rows are untouched.

  • #2649: AuditEventIngestRequest.source_service leaves the request body. Both ingest arms stamp it from principal.client()'s as_str() (the portal’s is canopy-portal). The route admits system tokens and the portal (M4).

SW8. canopy-web’s session store (R4: "replaces its schema outright")

One migration drops web_session, web_login_flow and web_session_end, and creates these tables. Ids are UUID v7.

Table Columns and constraints

web_session

id PK; token_hash BYTEA NOT NULL UNIQUE (SHA-256 of the cookie token); csrf_token TEXT NOT NULL; created_at, idle_expires_at (indexed) TIMESTAMPTZ NOT NULL; version BIGINT NOT NULL ≥ 1; claim_id UUID, claim_expires_at TIMESTAMPTZ (both or neither); record JSONB (a WebSessionRecord; NULL or undecodable reads Claimed::Undecodable); studio_draft JSONB

web_native_session

id PK; subject TEXT NOT NULL (indexed); created_at; version; claim_id/claim_expires_at (both or neither); record JSONB; due_at TIMESTAMPTZ NOT NULL (indexed; mirrors the record’s maintain_at)

web_session_end

session_id PK; kind CHECK (web, native); token_hash BYTEA (indexed; NULL for native); subject TEXT; created_at, ended_at TIMESTAMPTZ NOT NULL; reason CHECK (WebSessionEndReason's nine); superseded_by UUID

web_login_flow

id PK; flow_hash BYTEA NOT NULL UNIQUE; state_hash BYTEA NOT NULL; kind CHECK (sign_in, step_up, device_approval); nonce, pkce_verifier TEXT NOT NULL; max_age_secs INTEGER; prompt_login BOOL NOT NULL; fresh_retry BOOL NOT NULL; return_to TEXT; replaces_session_id UUID; user_code TEXT (NOT NULL exactly when kind = 'device_approval'); expires_at NOT NULL (900 s)

Ends and replacement keep today’s semantics (web_session/store.rs):

  • Every end is one data-modifying CTE that deletes the row and inserts its end row.

  • Replacement (a re-sign-in or a step-up) is one transaction:

    1. end the old row as superseded, with superseded_by the new id;

    2. if nothing was ended and the old row’s end reason is signed_out or operator, refuse and roll back;

    3. insert the new row.

  • Logout ends by its cookie’s token_hash. Failing that, it follows superseded_by from the end row with that token_hash, up to four links (MAX_SUPERSEDE_LINKS).

  • So logout wins in both orders, and today’s race tests (a_logout_racing_a_completing_callback_ends_the_superseding_session and its reverse) port.

  • end_reason(key) reads the end row.

Flows.

  • A flow is written from PendingAuthorization::expose_for_store().

  • It is taken with the single-use DELETE … WHERE flow_hash = $1 AND state_hash = $2 AND expires_at > now() RETURNING ….

  • It is rebuilt with PendingAuthorization::restore(returned_state, nonce, verifier, max_age). The relying party’s 43-character state replaces today’s 22-character one.

Sweeps.

  • Every 300 s, a sweep ends idle web sessions (idle), deletes expired flows, and deletes end rows older than 30 days.

  • NativeSessions::sweep maintains native sessions every 30 s.

The record stays plaintext JSONB, as today’s grant is (field encryption is #2521).

The implementation. PgWebSessionStore (key: the session id) implements WebSessionStore, and PgNativeStore implements DueSessions. Their DB tests run contract::check and contract::check_due; canopy-web’s dev-dependency enables canopy-auth’s test-helpers.

Existing sessions and Studio drafts are dropped. Pre-1.0, workers sign in again.

SW9. canopy-web signs in and calls through canopy-identity (W1, V1, X1–X8)

Boot. canopy-web reads:

  • the upstream profile (identity-upstream.yaml, mounted read-only as canopy-security mounts it);

  • CANOPY_WEB__UPSTREAM_CLIENT_SECRET (SW2);

  • CANOPY_WEB__IDENTITY_CLIENT_PRIVATE_KEY;

  • the identity settings.

It builds:

  • UpstreamRelyingParty;

  • FederationClient;

  • WebSessionEngine over PgWebSessionStore;

  • WebSender::from_secrets;

  • NativeSessions over PgNativeStore;

  • AdminClient;

  • EdgeForwarder.

Sign-in. A browser reaches Kanidm only by navigation, never by a redirect that follows a form submission. CSP’s form-action 'self' blocks those in Chromium, as auth/handoff.rs records. That module stays for every such step, and so does the cross-site callback’s SameSite=Strict fix.

Route Behaviour

GET /login

Renders the AC-8 page: the notice and a Continue link

GET /login/start

Creates the sign_in flow (prompt=login after a sign-out, per D6), sets the flow cookie, 303 to Kanidm. A plain navigation, as today’s /login is

GET /auth/step-up?return_to=…

Creates a step_up flow (step_up_options()), 303 to Kanidm

GET /auth/callback

Takes the flow and completes it by kind, then answers the handoff page to return_to, never a redirect (see below)

POST /logout

sign_out, then the handoff page to the end-session URL where advertised, else to canopy-web’s signed-out page (Kanidm advertises none)

The callback completes each kind as follows:

  • sign_in: complete_sign_in, then a new session row (a replacement when the flow names replaces_session_id);

  • step_up: a replacement;

  • device_approval: complete_approval.

A SignInError::Federation of auth_time_too_old (F4: a stale upstream sign-in) restarts the flow once with prompt=login (fresh_retry). A second refusal, like any other federation refusal, renders the refusal page with its code, missing_primary_programs included (C8).

Removed: /auth/select, /v1/auth/discover, /auth/local-login, IdpRuntime, the Keycloak parts of the auth/ tree, the old web_session/ store, api/mock_exchange.rs and their tests. D1 allows one upstream.

The AC-8 notice is jurisdiction.toml's new required [sign_in] system_use_notice, a list of paragraphs, parsed by canopy-composition and validated non-empty.

  • default and georgia carry the DoD Notice and Consent Banner (public domain), with "U.S. Government" read as "State of Georgia" in georgia. Its three paragraphs:

    1. You are accessing a U.S. Government information system, which includes this computer, this network, all computers connected to this network, and all devices and storage media attached to this network or to a computer on this network. This information system is provided for U.S. Government-authorized use only.

    2. Unauthorized or improper use of this system may result in disciplinary action, as well as civil and criminal penalties.

    3. By using this information system, you understand and consent to the following: you have no reasonable expectation of privacy regarding any communications or data transiting or stored on this information system; at any time, and for any lawful Government purpose, the Government may monitor, intercept, and search and seize any communication or data transiting or stored on this information system; any communications or data transiting or stored on this information system may be disclosed or used for any lawful Government purpose.

  • test-max and test-min carry "This is a test system. Do not enter real personal information."

Roles.

  • WorkerRole gains SecurityAdmin, last in from_roles' precedence before Unprivileged. So a session holding only security_admin is admitted.

  • Its handling at the six WorkerRole matches:

    Match SecurityAdmin

    as_str, role_slug_for_worker

    security_admin

    worker_role_display

    "Security administrator"

    surface_for_role, and the dashboard’s two redirect sites

    Redirect to /admin/security, as Auditor's does to /audit-log

    alerts_url_for

    None

    admit_role

    Admits it

  • can_write and every matches! gate leave it out.

  • A session’s security_admin capability is read from its roles, not its WorkerRole. So a worker holding a case role and security_admin keeps their case landing and sees the "Security administration" nav link (base.html, both nav copies).

Extractors. require_auth serves through WebSessionEngine::current. A request’s SignedInWorker carries the subject, roles, programs and username from the session’s F2 answer (ADR-044: programs come from federation).

Calls.

  • A middleware inside the protected stack builds WebSender::calls(session key, live, deadline) per request and inserts Arc<WebOutbound>.

  • ServiceClients and InternalClient lose their stamped token. Each call goes through send_with_retry with the request’s deadline.

  • with_service_identity, svc_token, the exchanger and the six exchanged/review wrappers go.

  • WorkerObservedSink and the worker-name refill take WebSender::system_bearer(Security).

  • The panel cache keys on (service, url, subject) (#2647). Every call carries the worker’s delegation, so the day-30 shadow-findings call carries its identity (#2803).

The route-authz gate (xtask/src/cmd/route_authz.rs):

  • The new sign-in routes are GETs in main.rs, taint-checked like today’s /login.

  • /auth/callback stays in GET_TAINT_EXCEPTIONS.

  • The removed routes' entries go.

  • EXPECTED_MUTATING_TOTAL is recomputed in each unit that changes it.

SW10. canopy-web’s new pages (Y1, Z1, Q7)

Security administration (services/canopy-web/src/admin_security.rs, mounted in the protected stack by admin_security::routes()). Its extractor admin_security::SecurityAdminOnly requires security_admin; a session without it gets the 403 page.

Method Path Does

GET

/admin/security

Look up a subject by ?issuer=&subject= or ?id=

GET

/admin/security/subjects/new

Create form

POST

/admin/security/subjects

Create (K5)

GET

/admin/security/subjects/{id}

Links, sessions, suspension state

POST

/admin/security/subjects/{id}/suspend

Suspend

POST

/admin/security/subjects/{id}/lift

Lift

POST

/admin/security/sessions/{id}/revoke

Revoke (form carries the subject to return to)

GET

/admin/security/links/new

Re-link form

POST

/admin/security/links

Re-link

GET

/admin/security/keys

Signing keys

POST

/admin/security/keys/{kid}/revoke

Revoke a key

GET

/admin/security/clients

Clients

POST

/admin/security/clients/{client}/disable

Disable

POST

/admin/security/clients/{client}/enable

Enable

  • Each write takes an AdminReason and the checked id types, and redirects back (same origin) with a result notice.

  • A write answered StepUpRequired renders the handoff page to GET /auth/step-up?return_to=<the page>.

Device approval (services/canopy-web/src/device.rs, mounted by device::routes(), extractor device::ApproverSession, any admitted session):

Method Path Does

GET

/device

Code form

POST

/device

describe, then the confirm page

POST

/device/deny

Deny

POST

/device/approve

A device_approval flow via NativeSessions::step_up, answered with the handoff page to Kanidm

GET

/device/approved

Success, after the callback

GET

/device/sessions

The worker’s native sessions

POST

/device/sessions/{id}/revoke

Revoke this device. The row’s subject must be the worker’s; another worker’s session answers 404 before NativeSessions::revoke is called

  • Every invalid code shows one message. A 429 shows its wait.

  • A sweep task runs NativeSessions::sweep every 30 s.

The gate.

  • policy_for gains arms for admin_security.rs and device.rs.

  • SCOPE_POLICY gains NotProgramScoped entries for each new mutating handler.

The edge.

  • let edge_router = edge.router(); merges outside the session and CSRF layers, under the edge limiter, with TrustedProxies from CANOPY_TRUSTED_PROXIES.

  • COMPOSITION_ALLOWLIST gains ("services/canopy-web/src/main.rs", "merge", "edge_router"), justified like test_clock: canopy-auth’s forwarded identity routes, which take no cookie and change no canopy-web state (Q7).

SW11. Studio and the IdP tables (ADR-050 §2)

[identity], [[idp]] and [local_accounts] leave idp.toml, which keeps [roles.*] (ADR-022). Their removal reaches:

  • IdpDocument;

  • the four rulesets;

  • Studio’s step 2, its probe, IssuerProbeClient, canopy_auth::issuer_probe and their templates;

  • step2_route_infra_tests.rs;

  • the bundle’s render_idp_toml.

The wizard has four steps. A jurisdiction’s upstream is deployment configuration (ADR-050).

SW12. The portal, canopy-cli and the operator tools (O1, O5, O7)

The portal.

  • PortalSender::from_secrets (with send_with_retry) replaces PortalTokenSources at all 22 sites.

  • PortalConfig swaps its OIDC fields for the identity settings and reserves IDENTITY_CLIENT_PRIVATE_KEY.

  • tokens.rs, narrow_token_test.rs and the Keycloak start-race retry go.

canopy-cli.

  • Every command takes DeviceClient::token(CanopyService) through send_with_retry.

  • canopy login runs the device flow (begin_login prints the URI and code; complete_login polls). canopy logout and canopy token <service> stay.

  • Profile: it carries identity_issuer (the public issuer; the edge serves every endpoint) and an optional ca_file. The devstack profile derives both and pins web.canopy.test to docker::published_host().

  • Goes: login service, the password grant, exchange_for_audience, keycloak_*, devstack.rs's Keycloak proof, the notice mark-read verb (#2805), and their tests.

The operator tools.

  • sweep-finalize-orphans takes the operator’s device session from canopy-cli’s store for its profile (--profile).

  • identity verify and identity render --backend keycloak go. identity check stays.

SW13. The battery (K7, J1)

Rust. canopy-test-lib gains tokens, over one process-wide TokenBroker (BrokerConfig::from_env):

Helper Mints

worker(person, target)

A delegation as canopy-web

stepped_up(person, target)

A stepped-up delegation

system(client, target)

A system token

portal(target, scope)

The portal’s system token

cli(person, target)

A canopy-cli delegation, from a device session per person (below)

The broker’s canopy-cli sessions. TokenBroker gains a device session per person, all production grants (D14):

  • DeviceClient::begin_login as canopy-cli, over a store under the broker’s cache;

  • the broker approves the user code as canopy-web does: its spaced Kanidm sign-in, step_up_options(), and FederationClient::approve with the person’s web session;

  • complete_login.

Then DeviceClient::token(target).

cast(U) is the realm username, except admin, which is canopy.admin (K3). applicant.test has no account (D11), so its rows take the portal path.

Each Keycloak site maps by the route’s admission, in this order:

  1. A worker acting (a password grant, or an exchange as U) becomes worker(cast(U), target) when canopy-web holds a delegation edge to the target, else cli(cast(U), target).

  2. A service token on a route with a system arm becomes system(c, target):

    • under system_from(&[X]), c is X;

    • under system(), c is the first client in CALLERS order, excluding canopy-web, canopy-portal and canopy-cli, whose edge to the target is System or Both.

    • Every non-web via row has a system arm (21 of 21).

  3. A service token on a route with no system arm becomes worker(p, target) or cli(p, target), by which via actor the row lists. p holds the route’s role set, per the table below.

  4. canopy-web’s 18 service-token sites become worker.

  5. The portal’s scoped tokens become portal(target, scope).

  6. A test of eligibility’s onward hop calls eligibility as a worker, and eligibility delegates.

Role set Cast person

CASEWORKER_WRITER_ROLES, CASEWORKER_OR_ABOVE_ROLES

jane.caseworker

CASE_READER_ROLES

jane.qc

WORKER_READER_ROLES, AUDIT_READER_ROLES

jane.auditor

SUPERVISOR_VIEW_ROLES, supervisor/admin

jane.supervisor

admin

jane.admin

quality_control

qc.reviewer

data_steward

data.steward

fti_auditor

fti.auditor

studio_admin

jane.studio

security_admin

sec.admin

Negative tests keep the property they assert, not the token they used:

  • A token the issuer will not mint (no edge) becomes two assertions: the broker reports the issuer’s refusal, and the receiver refuses the nearest mintable token (another receiver’s, 401 token_rejected).

  • Example: rules' worker_tokens_rejected_post_cutover asserts:

    • canopy-web cannot mint a rules delegation;

    • a persons delegation is refused by rules;

    • a cli delegation from a person outside CASEWORKER_OR_ABOVE_ROLES (jane.studio) is refused 403 required_role_missing;

    • a cli caseworker is admitted, per I3c2’s rows.

Other Rust test changes:

  • Lifetime: no test holds a token past one minute; long tests re-mint, which is cheap because the broker reuses sessions.

  • The 11 receiver_contract_test.rs become identity contract tests. Per service they cover:

    • no bearer: 401 token_missing;

    • another receiver’s token: 401 token_rejected;

    • X-Canopy-Actor: 400 actor_header_retired;

    • a cast worker lacking the role: 403 required_role_missing;

    • the portal on a non-portal route: 403 portal_on_non_portal_route, where the service has a portal route.

  • The qc_read_only tests take worker("qc.reviewer", …).

  • mock_issuer.rs keeps its upstream surface: discovery, JWKS, userinfo, minting, and whichever /token arms a canopy-identity suite or the perf substrate uses. It drops introspection, client credentials, RFC 8693 exchange and discovery()'s OidcDiscovery.

  • Deleted: introspection_mock_issuer_test, claim_contract_mock_issuer_test, issuer_probe_test, trusted_issuer_discovery_test, exchange_audit_e2e_test, the F4 Keycloak conformance matrix (conformance_matrix_test and conformance.rs), and in-service tests of Keycloak itself (rogue exchanger azp, direct versus exchanged, broad and multi-audience, the hop-two pair, the Keycloak-user fresh hire, the src infra tests building Keycloak sources).

  • loud_miss_pin scans follow the new names. auth.rs goes with its last caller in U17.

The Kanidm lane’s oracle stays independent of canopy-auth’s validator (idp_conformance_kanidm.rs's module doc). Before U19 deletes jwks and claim_contract:

  • login.rs's verify takes a private copy of bind_algorithm's algorithm-to-key binding, and its access-token checks keep that oracle.

  • oidc_generic_contract()?.project(…) becomes upstream::project over an oidc-generic UpstreamProfile, with the conformance assertions reading FederatedIdentity's sub(), roles() and programs().

Playwright.

  • auth/setup.ts: signs its nine workers in with routeUpstreamSignIn at canopy-web’s origin and saves their storage states. Each run signs in afresh: clear_playwright_auth_cache and the cache mount go.

  • Budgets: auth-setup, journey and every project whose specs call the helper inline (auth, auth-cross-site) take the identity-plane budgets: timeout: 300_000 and navigationTimeout: BROKER_BUDGET_MS.

  • TLS trust: Chromium pins the ingress leaf’s SPKI battery-wide. xtask computes CANOPY_E2E_WEB_SPKI from the leaf it generated, and playwright.config.ts adds it to every project’s launchOptions.args. ignoreHTTPSErrors is never used. Node trusts the devstack CA through NODE_EXTRA_CA_CERTS (the CA installed into canopy-e2e’s inputs).

  • The given helpers: lib/given/auth.ts gives way to broker helpers mapping by Rust’s rules, across 35 files.

  • Specs:

    • auth.spec.ts asserts canopy-web’s own sign-out: the session ends, /login shows the notice, jane.unscoped’s refusal page, and the stale-SSO restart’s single retry.

    • auth-cross-site.spec.ts signs in at the xsite origin.

    • The two journeys' inline sign-ins take the helper.

    • Studio’s three issuer-probe tests go.

  • A real redirect chain. The @identity spec gains "a worker signs in to canopy-web through Kanidm’s pages", once at each origin. A Chromium pinned to Kanidm’s and the ingress’s leaves goes:

    1. /login, then Continue;

    2. Kanidm’s pages (the page object);

    3. the callback’s handoff;

    4. signed in.

      The xsite run proves the SameSite=Strict session cookie arrives.

  • cargo xtask e2e brings the broker up for every run. The no_ci_e2e_run_starts_the_token_broker pin flips to "every run starts it", and CI’s e2e lanes build the broker image in their daemon.

k6. All four profiles take per-VU createTokenCache tokens: system('canopy-eligibility', …) for their targets. smoke drops its unused worker token. perf brings the broker up for every profile, and KEYCLOAK_URL goes.

SW14. Deletion (K1)

U19 deletes what earlier units have not:

  • Devstack: the devstack’s Keycloak directory, the compose service, its 21 depends_on, and every OIDC_*, exchanger, audience and EXCHANGE_TARGETS key.

  • xtask:

    • the Keycloak port (PORTS_ENV_VERSION bumped);

    • realm drift, heal and reimport (dev reimport-realm), and the #1900 token-holder restarts;

    • the perf keycloak cell;

    • validate’s heal-realm-drift stage;

    • the call-graph advisories reading the legacy env;

    • validate-in-network’s realm pins;

    • issuer_http's password and secret grants.

  • canopy-auth: token_exchanger, service_token (and its BearerSource impl), jwks, identity_config, receiver, middleware, exchange_audit, policy, validator and subject_bearer. Also:

    • introspection, except ServiceCredentials, which moves under upstream;

    • Claims, with ROLE_VOCABULARY and the role sets moving to canopy_auth::roles;

    • claim_contract, keeping only JsonPointer, which moves under upstream;

    • discovery, with TOKEN_EXCHANGE_GRANT moving to identity_session;

    • client_ext::with_service_identity, keeping ACTOR_HEADER and the finalize headers.

  • Other crates: canopy-api’s legacy BootstrapResult fields and bootstrap path; canopy-common’s nine settings.

SW15. Settled issues

  • Implemented here: #2649 (SW7), #2647 and #2803 (SW9), #2648 (SW5), #2805 (SW12), and #2344 and #2345 (the relying party, wired).

  • Superseded, each closed after merge with its mapping:

    • #1869: the exchange audit is gone (SW7).

    • #1901: ServiceTokenSource is gone, and the sender never fails open (E6).

    • #1447: every receiver has its own audience and checks a system token’s edge (L3), and each contract test refuses another receiver’s token.

    • #1595:

      • JWKS non-200 maps to a_defective_answer_is_a_failed_fetch and a_failed_refresh_keeps_the_set_until_it_is_stale.

      • The stale bound maps to a_set_past_720_s_fails_closed.

      • Leeway maps to identity_token's time-rule tests.

      • Discovery, introspection and exchange no longer exist.

SW16. New input surfaces

The admin forms, the device forms and the sign-in routes' query parameters get evil-input cases (oversized fields, control characters, non-UTF-8, malformed ids and codes). Each asserts a 4xx, no echo of the input, and no state change. The checked types (AdminReason, CheckedPair, UserCode) already carry their own proptests.

Units

Subjects are at most 72 characters, ending in (#N). Every unit follows SW1.

Erratum (2026-10-12): U2’s ingresses are ingress and ingress-xsite (the canopy- prefix marks fleet application services in xtask), both in every profile so the xsite origin’s port and registered redirect hold without an e2e run; web.canopy-xsite.test stays canopy-web-xsite’s alias, and canopy-web keeps publishing its http port, until U9 serves the https origin, and TestConfig.web_url, CANOPY_E2E_BASE_URL and CANOPY_E2E_XSITE_BASE_URL move with U9 and U18 (SW6’s table corrected). Kanidm’s canopy-web redirects leave the static migration, which Kanidm re-applies at every start, and xtask sets them over REST on every bring-up and records them in the Kanidm credentials file (Credentials.redirect_uris); the broker and the devstack tests read them there (identity_broker::registered_redirect), not from CANOPY_TEST__WEB_ORIGIN. The shared published-host rule is canopy_test_lib::docker_host, and the web client is web_origin::web_client.

Erratum (2026-10-12): U3 delivers the client keys and canopy-web’s Kanidm client secret through per-client env files that docker-compose.yml names as env_files, not interpolated variables, so every compose invocation carries them (SW5’s paragraph corrected); it reserves IDENTITY_CLIENT_PRIVATE_KEY (and canopy-web’s UPSTREAM_CLIENT_SECRET) in each client service’s RESERVED_KEYS, which SW3 placed in U4, since the injection is what requires them. canopy-web-xsite is not among the TLS and profile readers restarted: cargo xtask e2e removes it after every run, so it always starts on the current material.

Erratum (2026-10-12): U4 builds the shared clients and CallerContext on BearerSource as SW5’s corrected bullets say (PersonsClient::system / on, RulesClient's per-call source, rejected async). The bootstrap builds the receiver and sender before any connection, so a missing client key refuses the boot before migrations; each service layers its Arc<IdentitySender> as an extension in the unit whose handlers first send through it (U6, U7). Tests build a user or system Principal with canopy_auth::identity_receiver::test_principal (test-helpers), and an AppState with canopy_test_lib::identity::offline_receiver or devstack_receiver; a call to a stub receiver takes canopy_test_lib::identity::FixedBearer. canopy-test-lib’s library enables canopy-auth’s test-helpers, which no production image builds.

Erratum (2026-10-12): U6 hands each request’s handlers an owned outbound, canopy_auth::RequestOutbound, which request_outbound_middleware (installed inside the receiver with the service’s sender) inserts as an extension, in place of a SharedOutbound each handler builds; a test inserts a FixedBearer in its place. A service-local client holds the sender (system origin) and on(source) swaps in a request’s outbound where a call carries the caller; existence probes (canopy-validators) and shared bookkeeping (appeals' adverse-action stays) stay on the sender, as B4 allows. SW4’s appeals and reporting operator routes admit canopy-cli as written, but the compiled graph holds no canopy-cli edge to either service, so they admit no caller until #2886 settles one. canopy-security and the other admin routers keep their ReceiverContract until U7 ports canopy-api’s admin routes.

Erratum (2026-10-12): U7 renames PersonsClient::system to calls (U4’s erratum corrected) and adds with_source, so a request’s copy of a shared client carries the caller: canopy-applications' deps extractors, ReopenSagaDeps::on and PostponementSagaDeps::on (inline saga drives included) build theirs on the request’s outbound, and the other service-local deps gain on(source) as in U6; canopy-reporting’s clients retry a 401 around canopy_api::retry, which owns each send. canopy-overpayments' list admits by the mounting service’s delegated constant, which the mounting router layers as an api::ListAdmission (api::routes(admission) does; canopy-snap layers its own beside its create handler). CallerContext goes: the TANF and Medicaid determine take the Principal and a BearerSource. Eligibility’s run config carries the request’s outbound and the sender (DetermineConfig { source, system }), the sender for the reads I3c2 M4 keeps system (the replayed operation’s envelope; the bulk-run admin routes' corpus, provenance and universe reads); EXCHANGE_TARGETS leaves its config and docker-compose.yml, and its SSA SOLQ pre-dispatch stays off in development (#2495), which the retired key’s absence ensured. canopy-reporting has no service-only route, its run reads dropping the service arm (no system edge), so #2886 concerns appeals alone. The snap and medicaid provenance gates and canopy-applications' determination context admit canopy-eligibility by principal.client(), its onward delegation as well as its system token.

Erratum (2026-10-12): U8 removes the ingest’s auth.token_exchange arm and every intake-side dedup producer (the bus arm’s parse, the v1 append’s key probe, the staged row’s unhashed key); ChainAuditSink stays, naming no source, until canopy-web’s exchanger goes in U9. The chain-v2 drainer keeps honoring a dedup key on rows staged while the exchange audit ran, and the dedup_key columns stay. The intake’s poison tests quarantine a number-fence failure in place of a retired purpose. audit_ingest_test.rs loses its three exchange-arm tests and exchange_audit_e2e_test.rs its jti-replay test; its round trip still asserts canopy-portal as the source, so U16 asserts the id of the client its token is minted for instead.

Erratum (2026-10-12): U9 evolves web_session/ in place: the store, flows and sweep keep their files, the Keycloak grant gives way to record.rs's WebSessionRecord encoding, and engine.rs and native.rs hold the two WebSessionStore implementations. Handlers keep SessionData, built per request by SessionData::admit from the served session, in place of a SignedInWorker. The serve binds the boot roster, layered only as clients::SharedRoster, to each request’s outbound, so a handler can extract no unbound roster; InternalClient keeps its own transient-retry and deadline loop and re-mints once after a 401 inside it, under RETRY_FLOOR, rather than through send_with_retry (no canopy-web upstream answers a step-up challenge; the security-admin calls take AdminClient in U10). The callback refuses a device_approval flow; its completion, NativeSessions and the native sweep move to U11, and AdminClient and EdgeForwarder are built in U10 and U11 with their routes. The base.html "Security administration" link moves to U10 with the pages it names; until U10, a worker whose only role is security_admin is admitted and redirected from / to /admin/security, which U10 adds, and SessionData::is_security_admin lands with its tests for U10’s extractor and link to read. The sign-in routes' evil-input cases assert no echo, no stored return path and no 5xx, not a 4xx: #2520’s validator drops a refused return_to rather than refusing the request, and it gains a 2 048-byte cap. A role whose / redirects away is named once, api::dashboard::landing_elsewhere. The route harnesses take counted fixed bearers (HarnessBearers), asserting each upstream call’s delegation. step2_route_infra_tests.rs signs its worker in through the scripted sign-in (auth::test_support::World) until U12 deletes the step. canopy-web keeps publishing its http port, and TestConfig.web_url its http default, until U18 moves the e2e battery to the https origins (U2’s erratum corrected).

Erratum (2026-10-12): U10’s pages share one template, its view chosen server-side, and the nav link reads NavRole, the type every page’s worker_role_slug now has: the role’s slug plus the session’s security_admin. WebIdentity holds the AdminClient, and SecurityAdminOnly carries the request’s outbound, the client and the theme. A write’s form is read through AdminForm, which refuses a body that is not UTF-8 before a lossy decode could pass it. admin_security::routes() is generic over the router’s state, which no handler reads, so the route tests mount it on the scripted world.

Erratum (2026-10-12): U11’s approval flow stores the approving worker’s web-session id in web_login_flow.replaces_session_id, which the callback serves to complete the approval, since the upstream’s cross-site return carries no SameSite=Strict session cookie; its stale step-up retry takes the step-up options. Code entry’s and approval’s refusals add user_code_invalid and approver_mismatch to auth::Refusal. ApproverSession serves the worker’s web session again for code entry, which presents it. WebIdentity holds the NativeSessions; main.rs builds the EdgeForwarder and merges it into the outer router before the per-IP limit.

Erratum (2026-10-12): U12 retires [[idp]] and [local_accounts], but [identity] stays in the rulesets until U19: the legacy bootstrap’s IdentityConfig::load, which SW1 keeps to U19, refuses a boot without it. IdpDocument accepts the table unread (LegacyIdentityTable; the shipped rulesets' tables are checked through IdentityConfig in idp_test.rs), and the Studio bundle no longer renders it, so a bundle generated between U12 and U19 boots only once U19 deletes the legacy bootstrap. The probe’s runtime cap moves to canopy_auth::discovery::ISSUER_BODY_CAP until U19 deletes its readers, and canopy-api’s SharedKeyedLimiter, a general keyed limiter, stays without its one consumer.

Erratum (2026-10-12): U13 narrows SW5’s retry. A sender re-mints and resends only a 401 whose WWW-Authenticate is a Bearer challenge naming no error or invalid_token (canopy_auth::refuses_the_bearer), as every receiver’s and canopy-security’s admin guard’s token refusals are. A route’s own 401 (canopy-applications' wrong applicant credential, which a resend would check twice) and a step-up 401 are returned as they came, read from the challenge alone. canopy-web’s InternalClient loop and AdminClient take the same rule, and stub receivers answer canopy_test_lib::identity::bearer_rejected(). The portal builds its sender at boot, refusing the boot without its identity settings or key, and mints lazily, so the Keycloak start-race retry goes with no replacement; /readyz mints the canopy-applications token. The portal no longer reads idp.toml's [identity].

Erratum (2026-10-12): U14’s devstack is a reserved profile name derived on every run from .ports.env's CANOPY_TEST* keys (issuer, CA, service URLs), the issuer’s host pinned to CANOPY_TESTWEB_ADDR through IdentityHttpClient::with_trust; the global --devstack switch goes, and token show becomes token <SERVICE>. DeviceClient is a BearerSource whose rejected drops nothing, since each bearer is a fresh refresh. The sweep opens canopy-cli’s Session, so xtask depends on canopy-cli’s library. identity render goes whole (Keycloak was its only backend), and with identity verify gone U14 deletes issuer_http.rs and the devstack secret fallbacks SW14 gave U19. The broker’s device approval (TokenBroker::approve_device) lands in U14 for its devstack login test, and canopy-test-lib gains device_flow's stub issuer and receiver; U15 keeps the per-person device sessions and tokens::cli. cli_test.rs's Keycloak-token tests compile but fail until U17.

Erratum (2026-10-12): U15 keeps each person’s device store at <broker cache>/cli/<person> and serializes a login under the person’s cache entry, which approve_device now holds throughout. A stale device session is replaced, not awaited: the broker keeps no native record, so nothing renews it. BrokerConfig gains web_addr (CANOPY_TEST__WEB_ADDR), which the token-broker service’s compose block and xtask’s broker config now set. canopy-cli’s refresh and begin_login are retried on 503 like the broker’s other grants. The session-reuse and TOTP-spacing tests are one test, since only a fresh login makes the reuse check free of timing. The token-broker service answers a device error broker_failed until a unit has it mint canopy-cli tokens.

Erratum (2026-10-12): U16’s tokens::portal takes scope: Option<&str> (None: every scope, as the portal sends), and tokens adds or_skip (each helper as an Option, a miss reported through skip_or_panic), cast and system_caller (SW13’s system() rule over the compiled edges); bearer_sub, bearer_iss and mint_applicant_claim move into it. The mock issuer drops /token whole, since no suite or the perf substrate used any of its grants; TestClient::authenticated, uncalled, is deleted, and VerificationClient::with_token carries E8’s bearer. The QC write-gate sweep reads each handler’s admitted constant, which surfaces two write-verb routes admitting QC, waived: snap’s determination dry run, which is write-free, and rules' evaluate, whose only writes are its evaluation audit and telemetry, a read under SW4 and I3c2. The security and enrollment loud-miss pins scan the qualified tokens:: calls; applications' waits for U17. Appeals' canopy-cli operator routes admit no mintable caller until #2886 gives canopy-cli an edge to canopy-appeals and canopy-reporting; that defect is this branch’s, so #2886 lands on it after U16, and appeals' operator-route tests fail until then.

Erratum (2026-10-12): #2886 adds canopy-cli’s delegation edges to canopy-appeals and canopy-reporting, their profile URLs and the devstack profile’s derivation of them, and a command per operator surface: canopy appeal and canopy ipv for appeals' OPERATOR_READ, OPERATOR_WRITE and OPERATION routes, and canopy report for reporting’s routes but the overpayment summary canopy-web calls (every reporting route admits its roles through any actor, so the edge is their caller). No route’s admission changes.

Erratum (2026-10-12): U17 adds canopy_test_lib::identity::devstack_sender(client), a service’s real sender over the devstack, for in-process routers whose requests call live peers (canopy-applications' harness, eligibility’s bulk run). The applications suites file recertifications as a canopy-web worker: the renewed certification’s read rides the request’s outbound, and canopy-applications' edge to canopy-renewals is delegation alone, so a system-origin filing, which no production caller makes, answers 502. canopy-cli’s integration tests send tokens::cli delegations through ApiClient, and canopy_test_lib::auth is deleted with its last caller; the e2e and k6 helpers still name it until U18.

Erratum (2026-10-12): U18’s stale-SSO single retry has no e2e test: canopy-identity judges sign-in age on the wall clock and Kanidm stamps auth_time from the session the broker just opened, so no browser run can stage it; U9’s a_stale_upstream_sign_in_is_retried_once_with_prompt_login keeps it. auth and auth-cross-site become projects of their own, and routeSignInStart turns canopy-web’s /login/start 303 into a script navigation, which Playwright can route. The broker service gains POST /v1/tokens/cli. The TypeScript helpers mirror Rust’s tokens (orSkip answers null only when the broker is unreachable; a refusal throws), with systemArm, held and tokensAgain for long flows, and an xtask test holds their system-caller table to the compiled edges. canopy-web publishes no port (PORTS_ENV_VERSION 7): .ports.env drops CANOPY_E2E_BASE_URL and CANOPY_TESTWEB_URL, TestConfig.web_url reads CANOPY_TESTWEB_ORIGIN, and the clock-lane probe moves to canopy-applications. KEYCLOAK_REALM_AFFECTING_SERVICES keeps its canopy-web entry until U19 deletes the realm heal. k6’s profiles mint every target’s token as canopy-eligibility, which holds an edge to each, and k6’s Keycloak auth helper goes.

Erratum (2026-10-12): U19 removes ten legacy ServiceSettings fields, the exchanger pair counted as two, and the compose services' Keycloak-only extra_hosts with them. What the deletions leave unreferenced goes too: oauth_error, ServiceCredentials::sent_secrets, canopy-common’s deadline_retry and ApiError::identity_unavailable(), canopy-contracts-security’s token-exchange audit types, canopy-api’s SharedKeyedLimiter, canopy-test-lib’s JWKS chaos fixture and TestConfig.keycloak_url, and applicant from ROLE_VOCABULARY, which nothing reads once Claims::require_applicant goes. identity check caps the issuer’s answers at JWKS_BODY_CAP in place of the retired ISSUER_BODY_CAP. It also fixes the branch’s leftover unused dependencies (canopy-verification’s canopy-secrets and subtle, canopy-web’s jsonwebtoken), a canopy-web test reading an error’s top line for its chain, and the earlier units' broken private intra-doc links.

  1. U1 (#2864, w3) docs(adr): record the switch — type::documentation, service::security.

    • ADR-049 Amendment 25 (R24–R26, SW1–SW16), its Status line, and the amendments to K1, T5 and Consequences.

    • This page (In progress) and its nav group.

    • The 20 issues and the epic list.

    • The external-review issue (type::security, priority::high, workflow::blocked), related to &133.

  2. U2 (#2865, w5) feat(devstack): serve canopy-web at its https origin (SW6) — type::feature, service::devstack.

    • The ingress services and their volume install, the second leaf, the ports.

    • The issuer and device URI; the test inputs and published-host addresses; the broker’s redirect_uris and the helper’s membership check.

    • Tests:

      • the TLS pair and regeneration;

      • each ingress block (alias, same-port, the XFF overwrite line, healthcheck, non-root, no build);

      • the issuer pins;

      • web_client() and Kanidm’s pin under a tcp:// DOCKER_HOST;

      • the helper accepts both registered redirects.

  3. U3 (#2866, w5) feat(xtask): stage Kanidm and hand services their identity secrets (SW2, SW5) — type::feature, service::xtask.

    • The Kanidm phase on all four paths.

    • The provisioned origin and redirects.

    • The key and upstream-secret pairs in every up env, and the 15 interpolations.

    • The readers' restarts.

    • Tests:

      • each path’s order;

      • the secret in the stack’s up env;

      • each client block interpolates its key;

      • TLS_READERS and settle_profile name canopy-web.

  4. U4 (#2867, w8) feat(api): boot every service on canopy-identity (SW3, SW5) — type::feature, service::shared-crates.

    • Settings, mirroring and reserved keys; the bootstrap’s receivers and senders; AppState and its constructions.

    • BearerSource, SharedOutbound and send_with_retry; PersonsClient, RulesClient and their callers; signing_registration.

    • canopy-security’s receiver; exchange; depends_on; the test receivers.

    • Tests:

      • missing identity settings or key refuse boot;

      • each config loads with its injected key;

      • /v1 answers token_missing;

      • exchange mounts no /v1;

      • send_with_retry retries once after a 401, never after a step-up 401 or another status, and not under RETRY_FLOOR;

      • SharedOutbound's concurrent callers share one mint;

      • signing registration survives 70 s of temporarily_unavailable;

      • canopy-security’s issuer still loads.

  5. U5 (#2868, w3) feat(auth): name each delegated route’s admission (SW4) — type::feature, service::shared-crates.

    • Tests: the table’s rows equal the constants; the existing row tests.

  6. U6 (#2869, w8) feat(services): admit and send through canopy-identity, part 1 (SW4, SW5) — type::feature, service::persons.

    • persons, rules, security, verification (E8, the key deleted), notices (its CLI-operator routes), enrollment, renewals, appeals, caps, wic.

    • Tests: each service’s in-crate admission tests on Principal; verification’s internal routes refuse the key.

  7. U7 (#2870, w8) feat(services): admit and send through canopy-identity, part 2 — type::feature, service::applications.

    • applications, eligibility (onward delegation), snap, tanf, medicaid, reporting, canopy-overpayments, canopy-api’s admin routes.

    • Tests: as U6; eligibility’s fan-out delegates onward over one SharedOutbound.

  8. U8 (#2871, w3) feat(security): stamp audit sources from the client (SW7) — type::feature, service::security.

    • Tests: each arm stamps the authenticated client; the portal’s events stamp canopy-portal.

  9. U9 (#2872, w8) feat(web): sign in and call services through canopy-identity (SW8, SW9) — type::feature, service::web.

    • The migration and both stores; sign-in, step-up, callback, logout, the AC-8 page and its ruleset field.

    • Roles, extractors, the outbound middleware and roster; the wrappers deleted; the panel-cache key.

    • Tests:

      • contract::check and contract::check_due on Postgres;

      • the ported replacement and logout race tests;

      • the flow round trip through restore;

      • each callback kind answers a handoff;

      • the stale-SSO single retry;

      • the refusal page;

      • SecurityAdmin admission and landing;

      • one subject’s panel-cache entry is served to no other subject;

      • a receiver’s 401 re-mints once.

  10. U10 (#2873, w5) feat(web): add the security-admin pages (SW10, SW16) — type::feature, service::web.

    • Tests: a non-admin gets 403; each write’s reason and CSRF; StepUpRequired answers the handoff to /auth/step-up; the evil-input cases.

  11. U11 (#2874, w5) feat(web): approve devices and mount the identity edge (SW10, SW16) — type::feature, service::web.

    • Tests:

      • the invalid-code message;

      • a 429 wait;

      • /device/approve answers a handoff;

      • approver_mismatch approves nothing;

      • revoking another worker’s device answers 404 and revokes nothing;

      • the edge’s routes resolve;

      • the evil-input cases.

  12. U12 (#2875, w3) feat(web): retire Studio’s identity step (SW11) — type::feature, service::web.

    • Tests: the four-step wizard; the bundle has no identity tables; each ruleset parses with its notice.

  13. U13 (#2876, w3) feat(portal): send the portal’s calls with its sender (SW12) — type::feature, service::portal.

    • Tests: a target outside the nine is refused locally; a 401 retries once.

  14. U14 (#2877, w5) feat(cli): sign canopy-cli in with the device flow (SW12) — type::feature, service::shared-crates.

    • Tests: a devstack login approved through the broker’s device approval; canopy token; logout; LoginRequired under another issuer; the sweep with a device session.

  15. U15 (#2878, w5) feat(test-lib): mint canopy-cli tokens through the broker (SW13) — type::feature, service::shared-crates.

    • The broker’s device sessions and tokens::cli.

    • Tests: a cast person’s cli token is admitted by a via-CLI row; the session is reused; the TOTP spacing holds.

  16. U16 (#2879, w8) test: mint the Rust battery’s tokens through the broker, part 1 (SW13) — type::chore, service::shared-crates.

    • canopy-test-lib’s tokens and its own suites; the Kanidm oracle’s port.

    • persons, rules, security, verification, notices, enrollment, renewals, appeals, caps, wic.

  17. U17 (#2880, w8) test: mint the Rust battery’s tokens through the broker, part 2 — type::chore, service::applications.

    • applications (its harness on devstack_receiver), eligibility, snap, tanf, medicaid, reporting, web, portal, cli.

    • auth.rs deleted.

  18. U18 (#2881, w8) test(e2e): sign the e2e battery in through the broker (SW13) — type::chore, service::web.

    • auth-setup, budgets, TLS trust, given, specs, the real redirect chain, the xtask and CI broker wiring; k6’s four profiles and perf.

  19. U19 (#2882, w8) chore: delete the Keycloak path (SW14) — type::chore, service::devstack.

  20. U20 (#2883, w5) docs: describe the system on canopy-identity — type::documentation, service::security.

    • ADRs: ADR-049’s Status (effective) and Amendment 25’s as-built record. The detailed amendments of ADRs 007, 017, 019, 023, 037, 043, 044, 046 and 048, replacing their banners.

    • Pages: idp-integration, configuration-reference, local-dev (hosts, CA, ingress, the staged bring-up), security, security-operations (client-key rotation), deployment-guide (R24’s prerequisites, the proxy chain), services and the api/ pages, authorization-inventory, testing, shared-crates, canopy-cli, xtask-catalog, the finalize-orphan runbook, the guides, the walkthroughs and troubleshooting.

    • Close-out: CHANGELOG (Added, Changed, Removed, Security; the attribution change); the plan Done and archived; plan-lint --done with --allow-open for U1–U20, the external-review issue, the SW15 issues closed after merge, and Scope’s open issues; after merge, the SW15 closures and the epic’s tasks ticked.

Each unit updates the canonical page for its own surface (e.g. an API page whose route admission changed). U20 sweeps the rest.

Scope

In: K1’s switch, SW1–SW16, and the issues SW15 names.

Out:

  • #1303 and the external review (deployment prerequisites, R24).

  • #2804 (case tab role filter, a pre-existing defect).

  • #2811 (SAVE routes), #2790 (issuer pool bursts), #2846 (CIDR proxies), #2521 (session field encryption).

  • &134 (alternative upstreams).

Risks

  • A long local branch. Bundles after each unit; main barely moves (single developer); a rebase before the push.

  • Developer setup. Hosts entries and CA trust become necessary to sign in from a host browser. dev start prints both.

  • A moving issuer. A port move re-mints every token, and canopy-cli asks for a new login (SW6).

  • Battery time.

    • Each fresh auth-setup takes nine headless sign-ins, which run in parallel because each person is distinct.

    • The broker starts for every e2e and perf run, the pre-push smoke included.

    • canopy-cli sessions cost one device approval per person, reused afterwards.

  • canopy-security as a boot dependency of everything. Its receiver is in process and it calls no service.

  • Attribution change. System callers' audit rows carry the client id from the merge on (SW4, CHANGELOG).

Verification

  • Per unit: cargo check (SW1), fmt, clippy and unit tests on the touched crates, check-docs, plan-lint.

  • Before the push (on a devstack brought up from dev clean, so the staged bring-up and a fresh issuer are exercised):

    • cargo xtask validate (the pre-push battery: nextest including infra tests, e2e, docs, perf smoke);

    • cargo xtask e2e (every project, identity-plane and @identity included);

    • cargo xtask perf --profile load and --profile identity-tokens;

    • cargo xtask delegated-routes check;

    • cargo xtask identity check --client canopy-eligibility.

  • By hand, recorded in the MR:

    • a host browser signs in at https://web.canopy.test:<P>; past the AC-8 notice;

    • sec.admin suspends and lifts a subject through a step-up;

    • canopy login approved on /device, then canopy persons list.

Review log

Round Vendor Resolved model Verdict

1

Anthropic

claude-opus-5-5

No-ship. Nine blockers, fixed: compile order: SW1’s porting rule, the Keycloak pieces kept to U19, BearerSource;; the bootstrap rule: security, web and exchange; mirrored keys; the verifier; one shared-client API; the 401 helper;; SecurityAdmin admission, the route-authz entries, the named routes and the AC-8 text;; the full store schema;; the ingress, xsite, ports, test URLs and the web origin input;; the battery’s arm order and role-set table;; the corrected deletion lists;; the labels;; the ingress comparison and container rules. Cut per Q3: the ingest’s source_service field; the discovery module.

2

not stated (the maintainer’s other vendor)

not stated

No-ship. 19 findings (5 P1), fixed in-plan: the staged Kanidm bring-up before the stack (SW2);; reserved secret keys (SW3);; sign-in by navigation with the handoff kept, and a real redirect-chain spec (SW9, SW13);; the end log’s token_hash and today’s replacement and logout semantics (SW8);; the admission precondition and the canopy-cli path for edgeless service-only routes (SW4, SW13);; signing registration’s unavailable budget (SW5);; canopy-web among the TLS and profile readers (SW2);; published-host test addresses (SW6);; a build-free ingress via a volume (SW6);; port moves restated: no session ends, tokens re-mint, canopy-cli logs in again (SW6);; RulesClient on BearerSource (SW5);; send_with_retry keeps step-up classification and the deadline (SW5);; Arc handles and SharedOutbound (SW3, SW5);; the stale-SSO single retry (SW9);; device revocation’s ownership check (SW10);; the system-caller choice excluding web and the portal (SW13);; negative-test migration (SW13);; the broker budgets on every caller’s project (SW13);; the Kanidm oracle’s port (SW13).

Edit this page · default