Identity plane split, plan I3e4: the security-admin client (epic &133)
Status: Done (2026-10-10) — !1590
Epic: &133 (stage I3 of &130)
Issues: #2829 (U1, w2); #2830 (U2, w3); #2831 (U3, w5); #2832 (U4, w3).
MR: feat/identity-admin-client, "the security-admin client (#2829 … #2832)".
One MR, one commit per issue, under the maintainer’s one-MR-per-related-group ruling. It merges once the pre-push battery passes. This is a Design + Scope plan: GitLab owns tracking, and the plan freezes when U1 starts. Y1–Y5 are this plan’s decisions (ADR-049 Amendment 20); R9–R11 are the maintainer’s rulings.
Context
Amendment 17 W1 lists "the device-approval and security-admin clients" after canopy-web’s sender, which plan I3e3 built.
canopy-security serves the admin routes under /identity/admin/ (Amendment 8, H1–H2; services/canopy-security/src/identity/admin.rs and admin/):
-
the subject lookup and read, subject creation, suspend and lift, session revoke, re-link;
-
the key list and key revoke;
-
the client list, and client disable and enable.
The bearer is a canopy-identity delegation token for canopy-security, which needs security_admin. Its auth_time must be at most 600 s old (SECURITY_ADMIN_MAX_AGE_SECONDS); otherwise the answer is 401 with RFC 9470’s insufficient_user_authentication and max_age=600.
canopy-auth has no admin client today. canopy-web has no admin UI (that is the switch’s). canopy-test-lib’s broker has its own test client (identity_broker/links.rs), and the server’s tests each mirror the wire types locally.
The maintainer’s rulings (2026-10-10):
-
R9. W1’s stage splits: I3e4 is the security-admin client. I3e5, planned once I3e4 lands, covers device approval and native sessions.
-
R10. The admin wire types live in canopy-auth, shared by canopy-security’s routes and the client, so the wire contract has one source.
-
R11. A step-up asks for
max_age300 s: half the server’s 600 s bound. With the relying party’s 60 s leeway, that leaves at least 240 s of admin work (Y4).
Decisions (ADR-049 Amendment 20, Y1–Y5)
-
Y1. Staging (R9). I3e4 is canopy-auth library code, unwired until the switch, which builds canopy-web’s admin pages on it. Next come I3e5 (device approval and native sessions), then the edge forwarder.
-
Y2. The shared wire module,
canopy_auth::identity_admin(R10). Not one byte on the wire changes: field names,nullfor absent options (noskip_serializing_if), RFC 3339chrono::DateTime<Utc>times, every status and code.-
Path and limit:
ADMIN_PATH(/identity/admin) andADMIN_BODY_LIMIT(4096 bytes) move here. canopy-security’s router uses the limit as today. canopy-security and its one outside importer (services/canopy-security/tests/identity_admin/end_to_end.rs) import them from canopy-auth, with no re-export. -
Request bodies (
Serialize + Deserialize,deny_unknown_fields):ReasonBody { reason },CreateSubjectBody { subject_id, reason },LinkBody { upstream_iss, upstream_sub, subject_id, reason }. Their fields stayString, so the server keeps each field’s code and their order (body_invalid,upstream_pair_invalid,subject_id_invalid,reason_invalid). -
The lookup query,
UpstreamPair { upstream_iss, upstream_sub }, keeps today’sDeserializewithoutdeny_unknown_fields, so an extra query parameter answers as today. -
Checked input types, the rules' one Rust source (the migrations' CHECK constraints stay the store’s own). Each moves a check canopy-security has today, and the server calls it where it calls that check now, after parsing. The client’s methods take only these, so it never sends what the server refuses.
-
AdminReason::parse(&str): 1–200 bytes, no control character (writes.rschecked_reason). -
CheckedPair::new(iss, sub):iss1–2048 bytes of 0x21–0x7E;sub1–255 bytes of 0x20–0x7E (reads.rsvalid_pair). -
canonical_uuid(&str) → Option<Uuid>: lowercase hyphenated only (reads.rscanonical_uuid, moved unchanged). -
NewSubjectId::parse(&str): a canonical UUID that is not nil (today’s check increate_subject). -
AdminKid::parse(&str): 43 base64url characters, the last one ofAEIMQUYcgkosw048(writes.rscanonical_kid). -
Each refusal is a unit error type, except
NewSubjectId's, which isMalformedorNil. The server maps each onto today’s 400 code and message ("the id is malformed", "the nil UUID names no subject").
-
-
Responses (
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, every field documented). Ids are the transparent newtypes, so the wire is unchanged and a read’s id feeds a write without re-wrapping:-
SubjectRef { subject_id: SubjectId }; -
SubjectView { subject_id: SubjectId, links: Vec<LinkView>, suspended, sessions: Vec<SessionView> }; -
LinkView { upstream_iss: String, upstream_sub: String }; -
SessionView { session_id: SessionId, opener: String, auth_time, ends_at, fresh_until: Option<_>, revoked }.openerstaysString, the stored client id, so a client a reader does not compile never fails the read; -
Recorded { action_id: ActionId, changed: bool },ActionIda new transparent newtype over the action row’s v7 UUID; -
KeyListandKeyView { kid: String, created_at, sign_from, sign_until, publish_until, revoked_at: Option<_> }; -
ClientListandClientView { client: String, kind: ClientKind, registered, enabled, runtime_disabled },ClientKind::{Confidential, Native}writtenconfidentialandnative.
-
-
AdminProblem { code: Option<String> }: a deserializable view of the server’s problem body. A body that does not parse reads as no code. -
No database dependency. canopy-security keeps its private
sqlx::FromRowrows and maps each onto its view withFrom<Row>.
-
-
Y3. The client:
canopy_auth::identity_admin::AdminClient.-
Construction:
AdminClient::new(&IdentitySettings, IdentityHttpClient). Its base isIdentitySettings::admin_url(), a new field built asjwks_uriandtoken_endpointare (identity_endpoint(INTERNAL_URL_SETTING, &internal, "admin")). A test holds its path equal toADMIN_PATH. -
Methods, one per route, each taking the request’s
&WebOutbound<S>and only checked inputs.SubjectId,SessionIdandClientalready display canonically:-
lookup_subject(&CheckedPair)(GET…/subjects, the pair as its query),subject(SubjectId); -
create_subject(NewSubjectId, &AdminReason),suspend/lift(SubjectId, &AdminReason),revoke_session(SessionId, &AdminReason),link(&CheckedPair, SubjectId, &AdminReason); -
keys(),revoke_key(&AdminKid, &AdminReason); -
clients(),disable_client/enable_client(Client, &AdminReason).
-
-
Size: each write’s body is serialized once. One over
ADMIN_BODY_LIMITisBodyTooLarge, and nothing is sent. The checked types bound each field, not the escaped whole: three maximal fields of quotes make a 5,107-byteLinkBody. -
Answers: a read is 200 and its view; a write is 201 and
Recorded. Transport and classification live in free functions, keeping the impl under 16 methods and each function under 40 lines. -
The bearer is
calls.bearer(CanopyService::Security): a delegation in a request on canopy-web’sBothedge (X3). -
Bounds: each attempt is bounded by the lesser of
ADMIN_CALL_TIMEOUT(the server’s 5 s budget, H1, plus a 1 s transport margin) and what remains of the request’s deadline.WebOutbound::remaining(), private today, becomespub(crate). When less than a second remains, the retry is skipped:calls.rejected(Security)still runs, and the first 401 is classified as a second one would be. -
AdminErrorcarries no token, body text or reason. EachcodeisOption<String>, since some answers carry none, andmax_ageis aDuration.Answer AdminError401 whose
WWW-Authenticatechallenge carrieserror="insufficient_user_authentication"(RFC 9470 §3), or whose body’s code is thatStepUpRequired { max_age }: the challenge’smax_age, else 600 s. A small private function parses the challenge’serrorandmax_age.any other 401 (
token_rejected,token_malformed,session_ended,session_refused,client_disabled,token_missing, or no code)calls.rejected(Security)and one retry (E6, X8). The retry’s mint goes through the sender, which renews a stale session (X6), ends an ended one, and reports a disabled client. A second 401 isSessionEnded(session_ended,session_refused),ClientDisabled, orUnauthorized(code).403
Forbidden: nosecurity_admin, final400
Invalid(code)404
NotFound(code)409
Conflict413
TooLarge429
Limited(the limiter sends noRetry-After)503
Unavailable(code)any other status
Status(u16)no answer within the bound
Timeout, orTransporta success that is not its view
Malformedno bearer
Send(WebSendError)a body over
ADMIN_BODY_LIMITBodyTooLarge, nothing sentThe guard runs before every handler, so a retried write is never applied twice. The client retries only that one 401, never a step-up challenge (which would loop), nor anything else.
-
-
Y4. Step-up (R11).
STEP_UP_MAX_AGE: Duration(300 s) andstep_up_options() → AuthorizationOptions { max_age: Some(STEP_UP_MAX_AGE), prompt_login: false }. Kanidm honoursmax_age.-
The margin: the relying party admits an
auth_timewithinmax_ageplusLEEWAY_SECS(60 s, W5). A stepped-up session is therefore at most 360 s old, leaving at least 240 s of admin work under the server’s exact 600 s. Aconstassertion holdsSTEP_UP_MAX_AGE.as_secs()plusLEEWAY_SECS.unsigned_abs()(bychecked_add) underSECURITY_ADMIN_MAX_AGE_SECONDS.unsigned_abs(); all three live in canopy-auth. -
The flow: on
StepUpRequired, canopy-web (at the switch) authorizes withstep_up_options()(relying_party().authorization(redirect, &options), the pending authorization carryingmax_age), runscomplete_sign_in, and opens a new outbound over the new session. D6 holds: the new id_token opens a session carrying the newauth_time. -
The replaced session: the switch ends the record it replaced with a new
WebSessionEngine::supersede(key) → Result<Replaced, StoreFault>(U3), so a step-up leaves no live session behind.-
It ends the record as
Superseded, then revokes only its canopy-identity credential withinUPSTREAM_LOGOUT_TIMEOUT, assign_outdoes. It sends the upstream nothing.Replaced { ended, identity_revoked }says what it did. -
Not
sign_out: with no end-session endpoint, that revokes the old upstream refresh token. An overlapping leader that findsSignedOutalso revokes its rotated successor. An issuer that revokes related tokens could then end the new session, which is why the leader revokes no successor of aSupersededrecord (engine/leader.rsno_home).
-
-
-
Y5. The shared types' users.
-
canopy-security’s routes use them, with no behaviour change.
-
canopy-test-lib’s broker (
identity_broker/links.rs) uses them in place of its mirrors. The shared bodies' fields areString, so it formats itssubject_idUUIDs and passes itsupstream_subas text. It keeps its own transport: a fixed stepped-up bearer and aRetry-Afterloop. Itsupstream_issuer()becomespubfor U4. -
The server’s admin tests use them wherever a local mirror is the wire shape.
-
Units
Every commit goes through the J1–J8 review. Each subject is at most 72 characters with its ` (#N)`.
Erratum (2026-10-10): the checked types landed in identity_admin/checked.rs and the client’s tests in identity_admin/client/tests.rs. RETRY_FLOOR is public, and canonical_uuid and the checked types' bounds are exported. supersede's "a mint on it is refused" is proven by canopy-identity’s revocation being posted, the scripted world’s form of it. The sender tests' sender, live and far became pub(crate) for the client’s tests. U4’s attempts each take the plane tests' 15 s request budget as their outbound deadline, not 10 s, and its test reads the scratch subject back after each write.
-
U1 (#2829, w2)
docs(adr): record the security-admin client.-
ADR-049 Amendment 20 (R9–R11, Y1–Y5), plus the Status line.
-
This page (
In progress), with the** Identity Plane Split (epic &130)nav group above the archive line.
-
-
U2 (#2830, w3)
refactor(auth): share the admin wire types from canopy-auth(Y2, Y5).-
New module:
crates/canopy-auth/src/identity_admin.rs(+tests.rs): the wire types and checked types, re-exported inlib.rs. -
canopy-security:
identity/admin.rs,admin/reads.rsandadmin/writes.rsuse the shared types and checks. Their rows convert withFrom, andADMIN_PATHandADMIN_BODY_LIMITare imported. -
Callers:
-
canopy-test-lib’s
identity_broker/links.rs; -
the mirrors in
services/canopy-security/tests/identity_admin_test.rs,services/canopy-security/tests/identity_admin/end_to_end.rsandservices/canopy-security/src/identity/admin/tests.rs.
-
-
Tests:
-
each type serializes to today’s field names, with
nullfor absent options; -
proptest round-trips of every request and response type over arbitrary values;
-
an extra query parameter on the lookup answers as today;
-
each checked type’s table (bounds, control characters, canonical forms, the nil UUID, the kid’s last character);
-
proptests: no check panics on any input;
AdminReason::parseaccepts exactly 1–200 bytes without a control character; -
canopy-security’s admin tests pass unchanged in what they assert.
-
-
Docs:
shared-crates.adoc;api/canopy-security.adoc's admin section names the shared types.
-
-
U3 (#2831, w5)
feat(auth): add the security-admin client(Y3, Y4).-
Files:
-
identity_admin/client.rs(+tests.rs); -
identity_settings.rs'sadmin_urlfield and getter; -
WebOutbound::remaining()madepub(crate); -
identity_web_session/engine/sign.rs'ssupersedeandReplaced(+sign/tests.rs).
-
-
Tests, over a scripted loopback admin server and the sender over the delegation tests' endpoint (
engine_world, as I3e3’s tests):-
each method’s verb, path and JSON body;
-
each row of Y3’s table, including the challenge’s
max_ageparsed, and 600 s without one; -
a step-up recognized from the header alone (an empty body) and from the body’s code alone;
-
a proptest of the challenge parser: any header text gives a
max_ageor the 600 s fallback without panicking, and a well-formedmax_age=Ngives N; -
an error body with no code or not JSON (a plain-text 400, an empty 404, an ingress 503) gives
None, neverMalformed; -
one retry after each 401 code, with a new bearer, and no retry after a step-up challenge;
-
with under a second left, no retry: one request reaches the server,
rejectedran, and the first 401’s code picks the variant; -
403 is final;
-
the bound is the lesser of
ADMIN_CALL_TIMEOUTand the deadline; -
a malformed success;
-
admin_url().path() == ADMIN_PATH; -
a maximal quote-filled
LinkBodyisBodyTooLargewith no request sent, and a body of exactlyADMIN_BODY_LIMITbytes is sent; -
step_up_options(), and the compile-time check; -
supersede:-
it ends the record as
Supersededand revokes canopy-identity’s session (a mint on it is refused), while the scripted IdP receives no revocation or end-session request; -
with no record, it ends and revokes nothing;
-
a leader whose claim it ended revokes no rotated successor.
-
-
-
Docs:
shared-crates.adoc.
-
-
U4 (#2832, w3)
test(auth): prove the security-admin client on the devstack.-
The test file:
crates/canopy-test-lib/tests/admin_client_test.rs. It repeatsweb_sender_test.rs's plane construction, since each test file builds alone. -
The tests, one sign-in per test and per person, since the broker spaces each person’s sign-ins by 30 s:
-
sec.admin(the devstack’sLINKING_ADMIN) signs in withstep_up_options()(broker.upstream_sign_in, thenauthorization(&redirect, &step_up_options())). It readskeys,clientsand its own subject by upstream pair (upstream_issuer()and its Kanidm UUID). It then creates a scratch subject under a fresh v7 UUID, never a realm idlink_castlinks, asserts it is notsec.admin's own, and suspends and lifts it (Recorded,changed); -
jane.qcsigns in and isForbidden.
-
-
The per-IP limit, 60 a minute, is shared with
link_castand the broker’s tests, whose loop retries every second. Every admin call in the file therefore goes through a test helper,admitted. OnLimitedit waits 1 s and tries again, within a 120 s budget (the broker’sLIMIT_BUDGET). Each attempt runs over a fresh outbound (sender.callswith its own 10 s deadline), so no retry runs past an outbound’s absolute deadline. The client itself never retries a 429. -
What each run leaves behind: one scratch subject and three action rows, in insert-only tables.
-
devstack_identity_test.rs'slink_rows()counts every creation and link, assuming no other test writes one, so a concurrent scratch creation would break it. It now counts only actions whosetarget_subjectis a cast realm id (= ANY($1), bound tocanopy_test_lib::upstream::kanidm::PERSONS'realm_subject()s), and its doc comment drops the assumption. The scratch subject’s fresh v7 UUID is never a realm id. -
A real step-up challenge needs a session 600 s old, so U3’s scripted tests prove it, and this unit does not.
-
Close:
-
CHANGELOG.adocAdded(andChangedfor the move); -
Amendment 20’s as-built record;
-
the plan Done and archived;
-
plan-lint --donewith--allow-openfor U1–U4; -
after merge, update the epic.
-
-
Scope
In: the shared admin wire types and checked types; the client; the step-up options and the engine’s supersede; the devstack proof.
Out:
-
The switch: canopy-web’s admin pages and their step-up redirect.
-
I3e5: device approval and native sessions.
-
Moving the broker’s transport onto the client: the broker holds no
WebOutbound.
Risks
-
The move must not change the wire. U2 asserts today’s field names and codes, and the server’s own tests guard the behaviour.
-
A session’s
auth_timecan pass 600 s mid-page, a step-up landing between calls. Each call answersStepUpRequiredon its own, and canopy-web steps up once. -
Clock skew between Kanidm and canopy-security eats into Y4’s 240 s margin, since the guard has no leeway.
Verification
-
Per unit: fmt; clippy (workspace); quality-budgets, plan-lint, check-docs and private rustdoc.
-
nextest:
-
canopy-auth;
-
canopy-security’s admin tests (
cargo xtask test --integration --host -p canopy-security --no-refresh --skip-static); -
cargo xtask test --integration --host -p canopy-test-lib --no-refresh --skip-static(U4).
-
-
Per MR: the pre-push battery.
Review log
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic |
Claude Opus 5.5 (fresh subagent) |
no-ship. Three blockers, fixed in-plan:
|
2 |
not stated (the maintainer’s other vendor) |
not stated |
3 findings (P2) and 2 (P3), fixed in-plan:
|