Identity plane split, plan I2e: security administration (epic &132)
- Context
- Scope
- Design
- Decisions (recorded in ADR-049 Amendment 8, which lands with U1)
- U1: the database record (canopy-security)
- U2: the admin login’s pool (canopy-security)
- U3: authenticating security administrators (canopy-auth, canopy-security)
- U4: suspension and session revocation routes (canopy-security)
- U5: runtime client disablement (canopy-security)
- U6: re-linking (canopy-security)
- U7: key revocation route (canopy-security)
- U8: the in-process proof (canopy-security)
- Conventions every unit follows
- Units
- Verification
- Review log
Status: Done (2026-10-06) — !1573
Epic: &132 (stage I2 of &130)
Issues: #2729 (w5), #2730 (w3), #2731 (w5), #2732 (w3), #2733 (w5), #2734 (w5), #2735 (w2), #2736 (w3); follow-ups #2737, #2738
MR: feat/identity-admin: U1–U8 in order, titled "canopy-identity security administration (#2729 … #2736)".
The eight issues are one deliverable, security administration, and each unit depends on the one before, so they ship as one MR under the maintainer’s one-MR-per-related-group ruling, one commit per issue. U1’s commit adds this page and its nav entry: the group Identity Plane Split (epic &130) holding * Identity plane split, plan I2e — security administration (epic &132), placed just above ** Completed Plans Archive in docs/modules/ROOT/nav.adoc, as plans I2a–I2d did. U8’s commit closes the plan.
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U1 starts.
Context
ADR-049 D12 gives canopy-security four kinds of revocation: subject suspension, session revocation, client disablement and key revocation; "the admin routes require a security-admin role. They are surfaced in canopy-web, and every change is audited." D6 adds step-up: security administration needs an auth_time within 10 minutes. D8 and Amendment 6 F7 make re-linking an upstream identity to a subject a security-admin write.
In the tree today:
-
identity_suspend_subjectandidentity_lift_subject_suspensionare granted to nobody; the issuer probe enforces it (identity/probe.rs,NoSuspensionExecute), and operators run them as the migration identity (Security Operations).identity_revoke_keyis granted to nobody and has no Rust caller. -
Session revocation works by session id, but its reason CHECK has no admin cause (
logout,upstream_refused,projection_refused,upstream_changed,suspended), and itsclientcolumn is "always the session’s opener". -
Client disablement is the boot-read
enabledflag (Amendment 3 A7: "Runtime disablement is I2’s"). -
identity_subject_linksis immutable (PK (upstream_iss,upstream_sub), UNIQUE (subject_id,upstream_iss), a trigger refusing UPDATE and DELETE), so a renamed upstream issuer mints new subjects with no way back. -
ROLE_VOCABULARY(crates/canopy-auth/src/claims.rs) filters both projections and holds no security-admin role; xtask pins it to exactly the names a role check (has_role,require_any_role, …) reads. Today’s KeycloakClaimscarry noauth_time;DelegationTokenClaims.auth_timedoes. -
No route receives canopy-identity tokens yet.
IdentityTokenValidatorandMemoKeySourceexist, theJwksMemois shared inmain.rs, and the call graph hascanopy-web → canopy-securityasBoth. -
Each identity migration ends with an audit refusing any grant to a role but the owner and the issuer; the issuer’s matrix is hard-coded in
identity/probe.rs. Logins live indevstack/postgres/roles.sqlanddocker-compose.yml, settings keys inconfig.rs, pool labels in the closedPoolName; the lock inventories arecrates/canopy-test-lib/src/global_ddl.rsand xtask’s("security", 9)pin. -
The issuance log has no actor column and a closed
grant_typeset.
Scope
In scope: U1–U8 below.
Out of scope:
-
canopy-web’s admin screens and their
max_agesign-in (I3: canopy-web signs in through canopy-identity only then); -
a read route for the action log (#2737) and a replica rotating off its own revoked key (#2738);
-
device approval’s step-up (I2f);
-
the conformance manifest, which covers
/v1Keycloak-bearer routes only (documented, as for the token routes).
Design
Decisions (recorded in ADR-049 Amendment 8, which lands with U1)
| # | Decision | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
H1 |
The surface. Routes under
|
||||||||||||||||||||||||||||||
H2 |
Who may call. A canopy-identity delegation token for canopy-security, as
|
||||||||||||||||||||||||||||||
H3 |
The admin login. What the separation gives: the issuer can call no admin function and write no admin table, and its |
||||||||||||||||||||||||||||||
H4 |
Every change audited with it. An INSERT-only This narrows Amendment 6 F3: an admin change commits its action row, not an issuance-log row; the issuance log stays the issuer’s record. Exporting both through ADR-041 waits on #1301. |
||||||||||||||||||||||||||||||
H5 |
Suspension and session revocation. Suspend and lift call the existing writers with the actor’s subject as |
||||||||||||||||||||||||||||||
H6 |
Runtime client disablement. An INSERT-only |
||||||||||||||||||||||||||||||
H7 |
Re-linking. An INSERT-only Under those locks: an unlinked pair gets its base link (or relink version 1 when the target’s base link under that issuer already exists); a pair linked elsewhere gets relink n+1 and its live sessions revoked |
||||||||||||||||||||||||||||||
H8 |
Key revocation. |
U1: the database record (canopy-security)
-
Migration
20261216000000_identity_admin.sql: the role and its guards;identity_admin_actionsandidentity_client_disablements; reasonadmin;identity_revoke_sessionreplaced (H3);identity_admin_{suspend,lift,revoke_session,disable_client,enable_client,revoke_key}; admin grants; issuer SELECT on the disablements; the closing audit admitting the admin role; markers,global_ddl.rsand the xtask pin (10).identity/registry.rs'sREGISTRY_TABLESandREGISTRY_FUNCTIONS; the issuer probe (SELECT on the disablements, noidentity_admin_*). -
Tests (
tests/identity_admin_store_test.rs, anadmin_loginfixture intests/common/issuer.rs): each function’s change and action row together and a rollback leaving neither;changedon repeats; P0002, 23503, 23514; immutability; REPEATABLE READ refused 25000; the admin login refused direct writes, the issuer everyidentity_admin_*; the issuer’sidentity_revoke_sessionrefusingadminand accepting its own reasons. -
Docs:
data-models/canopy-security.adoc;security-operations.adoc(grants; the compromise response reviews admin actions byactor_token_kidand notes the routes are unavailable while the issuer is shut out); ADR-049 Amendment 8; this page and its nav entry. -
Erratum (2026-10-06): the
admin_loginfixture istests/common/admin.rs, over a role-agnosticmirror_loginintests/common/issuer.rs; the tests assert P0002 and 23514, since each function checks its target before writing, and add two racing transactions per locked change (disable, key revocation) settling to one change.
U2: the admin login’s pool (canopy-security)
-
CANOPY_SECURITY__IDENTITY_ADMIN_DATABASE_URLinconfig.rs;PoolName::IdentityAdmin(identity_admin) inPoolName::ALL; the censusNotPeerentry inxtask/src/cmd/call_graph/observed.rs;connect_admin_pool(4 connections,application_name = canopy-identity-admin); the strict admin probe;main.rsper H3;roles.sqland compose. -
Tests: the probe accepting the migrated grants and refusing a widened grant, a superuser and an issuer member; the pool’s doc table.
-
Docs:
configuration-reference.adoc; the pool-label lists inshared-crates.adocanddeployment-guide.adoc.
U3: authenticating security administrators (canopy-auth, canopy-security)
-
canopy-auth:
security_admininROLE_VOCABULARY(its tests, xtask’s scan),RoleSet::has_role,SECURITY_ADMIN_MAX_AGE. canopy-security:identity/admin.rs,admin/guard.rs(H2; the bearer’skidfrom its verified header; registry-enabledactclients), the router (H1) and the two subject reads. G5’s judgment moves toidentity/sessions.rsasSessionVerdict(Ended,Mismatch,Suspended,Stale), with its test; the mint maps it toCause, the guard to 401. -
Tests (in process, scripted sessions and keys): each H2 refusal in order with status and challenge (none, malformed, another receiver’s, a system token, unknown kid, revoked, suspended, stale, a registry-disabled client, non-admin);
auth_time600 s accepted, 601 s refused; stalled keys 503; the reads; no token logged; the evil-input corpus (jws_evil_cases!on the bearer, malformed and oversized bodies andreasons, bad path ids). -
Docs:
api/canopy-security.adoc(the admin section),security.adoc,authorization-inventory.adoc. -
Erratum (2026-10-06): the step-up bound is
SECURITY_ADMIN_MAX_AGE_SECONDS: i64(600), beside canopy-auth’s other session bounds in seconds; the guard checks it through a pureauthorized(claims, now), tested at 600 s and 601 s.
U4: suspension and session revocation routes (canopy-security)
-
The three routes. Tests (DB,
tests/identity_admin_test.rs, a federation-opened session): suspend stops the next mint (subject_suspended) and the admin’s own requests when the admin is the target; lift resumes; revoke ends minting (session_ended); the action rows' actor fields; 404 and 400. -
Erratum (2026-10-06): U4’s tests observe each effect in the store’s
mint_view, the row a mint judges (suspended,revoked), over a worker session written as the migration identity, as U3’s rig does; the token endpoint’ssubject_suspendedandsession_endedfor an admin write are U8’s end-to-end proof. They add a reason of exactly 200 bytes (ASCII and two-byte) accepted, and no refused write recorded.
U5: runtime client disablement (canopy-security)
-
identity/client_status.rs(ClientStatusMemo, injected clock), checked byClientAuthenticatoron all three paths and by the guard for everyactclient;ClientAuthRefusal::Disabled; issuer pool 18; the routes andGET clients. -
Tests: the memo’s bound on a fake clock, single flight, failure 503 with no stale set; disabled
invalid_clientwith its row and no jti spent; enabling restores; a YAML-disabled client stays refused; revocation refused; a pre-disablement admin bearer refused once the memo turns; DB route tests. -
Erratum (2026-10-06): the memo implements a
ClientStatustrait asked with the caller’s deadline;ClientAuthenticator::newandTokenEndpointPartsrequire one, so nothing defaults to "none disabled", and the check sits inauthenticate, which the three paths share, once the claims verify.GET clientsanswers{clients: […]}; a client id no compiled confidential client has is 404client_not_found. The SQL path that re-enables canopy-web passes the nil session, a fresh jti and the kidrepeat('A', 43), since every action row names an actor; the lockout test runs it.
U6: re-linking (canopy-security)
-
Migration
20261217000000_identity_relinks.sql: the relinks, reasonrelinked,identity_admin_link, the replaced functions with the pair lock, the actionlink, grants (admin and issuer SELECT on the relinks), audit, pins (11). Both probes' matrices and fixtures; the lookup and subject read on effective links;POST /identity/admin/links. -
Tests (DB): the rename scenario; pre-linking; a repeat;
link_conflict; an unknown subject; concurrency in both orders; two pairs re-linked to one subject at once (onelink_conflict); REPEATABLE READ refused; the reads after a re-link and after the collision fallback; both boot probes against the full migration set. -
Erratum (2026-10-06): the effective subject is read inline in each function, adding no helper to the function lists; each relink names its action (
action_id), and the action table gains shape CHECKs on the upstream pair; the open takes the pair’s shared lock too, so it holds when called on its own. The store-level tests aretests/identity_relink_test.rs, the route and read teststests/identity_admin_test.rs.
U7: key revocation route (canopy-security)
-
The route and
GET keys. Tests (DB): the JWKS omits the kid once its memo turns, and an onward subject token under it is refusedsubject_token_unknown_key; 404; a repeat. Docs:security-operations.adoc(the route is the path; the SQL stays for the compromise response). -
Erratum (2026-10-06): U7’s tests observe a revoked key’s tokens refused through the admin guard, which verifies with the same
IdentityTokenValidatorover the JWKS memo as the token endpoint’s onward check (token_rejectedonce the memo turns); the token endpoint’ssubject_token_unknown_keyfor an admin revocation is U8’s.GET keyslists the keys still in their publish window, revoked or not, at most 128, and answers{keys: […]}; a kid outside the registry’s shape is 400kid_invalid.
U8: the in-process proof (canopy-security)
-
services/canopy-security/tests/identity_admin/end_to_end.rs: a federatedsecurity_adminsession, canopy-auth’sDelegationTokenSourcefor canopy-security, each write route with its effect observed at the token endpoint, a non-admin refused 403, an 11-minute-old sign-in refused with the RFC 9470 challenge. -
Erratum (2026-10-06): the proof is two tests, the subject and session writes and the rest; the re-link’s target is a subject linked under the upstream’s old issuer, since one subject holds one link per issuer. The memos run on a manual clock.
-
Docs: Amendment 8’s as-built record. The plan closes here: Status
Done (YYYY-MM-DD) — !N; the page moved todocs/modules/ROOT/pages/plans/archive/, every xref following; the nav group removed and the archived entry appended, suffixed— DONE YYYY-MM-DD, as the last line of the Completed Plans Archive group;cargo xtask plan-lint --done docs/modules/ROOT/pages/plans/archive/identity-plane-split-i2e.adocwith--allow-openfor 2729 to 2738.
Conventions every unit follows
-
Every new input has its evil-input cases; errors never echo input; logs carry canopy subject and session ids, never a token, credential or upstream
sub. -
Times come from
chrono::Utc::now()(D14); tests inject clocks and never sleep. Database tests live intests/. -
Every unit ships its
CHANGELOG.adocbullet and the canonical page for its surface.
Units
-
U1 (w5) —
feat(security): record security administration in the database (#2729). -
U2 (w3) —
feat(security): connect as the security-admin login (#2730). -
U3 (w5) —
feat(security): authenticate security administrators (#2731). -
U4 (w3) —
feat(security): suspend subjects and revoke sessions by route (#2732). -
U5 (w5) —
feat(security): disable clients at runtime (#2733). -
U6 (w5) —
feat(security): re-link an upstream identity to a subject (#2734). -
U7 (w2) —
feat(security): revoke keys by route (#2735). -
U8 (w3) —
test(identity): prove security administration end to end in process (#2736).
Verification
-
Per unit: fmt; clippy in both profiles; nextest for canopy-auth and canopy-security;
rustdoc-private;quality-budgets;feature-builds;migrations-lintanddb-pools(U1, U2, U5, U6); the named database tests withCANOPY_TEST_INFRA=requiredagainst a reloaded devstack. -
End to end: U8 drives every write route with a real federated security admin and observes each effect at the token endpoint.
-
Per MR:
cargo xtask dev reload, thengit push(the pre-push battery).
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-10-06) |
Anthropic |
claude-opus-5-5 |
no-ship. Two blockers, fixed: an open racing a re-link could neither open as the new subject nor be revoked, and crossing re-links could deadlock (H7’s pair lock and ordered subject locks); admin session changes skipped F3’s issuance-log row unstated (H4’s narrowing). Also taken: the registry scan lists, the census entry, |
2 (2026-10-06) |
human-run |
not stated |
Seven findings, all fixed: an existing admin bearer outlived its client’s disablement (H2 checks every |