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_age 300 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, null for absent options (no skip_serializing_if), RFC 3339 chrono::DateTime<Utc> times, every status and code.

    • Path and limit: ADMIN_PATH (/identity/admin) and ADMIN_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 stay String, 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’s Deserialize without deny_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.rs checked_reason).

      • CheckedPair::new(iss, sub): iss 1–2048 bytes of 0x21–0x7E; sub 1–255 bytes of 0x20–0x7E (reads.rs valid_pair).

      • canonical_uuid(&str) → Option<Uuid>: lowercase hyphenated only (reads.rs canonical_uuid, moved unchanged).

      • NewSubjectId::parse(&str): a canonical UUID that is not nil (today’s check in create_subject).

      • AdminKid::parse(&str): 43 base64url characters, the last one of AEIMQUYcgkosw048 (writes.rs canonical_kid).

      • Each refusal is a unit error type, except NewSubjectId's, which is Malformed or Nil. 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 }. opener stays String, the stored client id, so a client a reader does not compile never fails the read;

      • Recorded { action_id: ActionId, changed: bool }, ActionId a new transparent newtype over the action row’s v7 UUID;

      • KeyList and KeyView { kid: String, created_at, sign_from, sign_until, publish_until, revoked_at: Option<_> };

      • ClientList and ClientView { client: String, kind: ClientKind, registered, enabled, runtime_disabled }, ClientKind::{Confidential, Native} written confidential and native.

    • 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::FromRow rows and maps each onto its view with From<Row>.

  • Y3. The client: canopy_auth::identity_admin::AdminClient.

    • Construction: AdminClient::new(&IdentitySettings, IdentityHttpClient). Its base is IdentitySettings::admin_url(), a new field built as jwks_uri and token_endpoint are (identity_endpoint(INTERNAL_URL_SETTING, &internal, "admin")). A test holds its path equal to ADMIN_PATH.

    • Methods, one per route, each taking the request’s &WebOutbound<S> and only checked inputs. SubjectId, SessionId and Client already 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_LIMIT is BodyTooLarge, and nothing is sent. The checked types bound each field, not the escaped whole: three maximal fields of quotes make a 5,107-byte LinkBody.

    • 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’s Both edge (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, becomes pub(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.

    • AdminError carries no token, body text or reason. Each code is Option<String>, since some answers carry none, and max_age is a Duration.

      Answer AdminError

      401 whose WWW-Authenticate challenge carries error="insufficient_user_authentication" (RFC 9470 §3), or whose body’s code is that

      StepUpRequired { max_age }: the challenge’s max_age, else 600 s. A small private function parses the challenge’s error and max_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 is SessionEnded (session_ended, session_refused), ClientDisabled, or Unauthorized(code).

      403

      Forbidden: no security_admin, final

      400

      Invalid(code)

      404

      NotFound(code)

      409

      Conflict

      413

      TooLarge

      429

      Limited (the limiter sends no Retry-After)

      503

      Unavailable(code)

      any other status

      Status(u16)

      no answer within the bound

      Timeout, or Transport

      a success that is not its view

      Malformed

      no bearer

      Send(WebSendError)

      a body over ADMIN_BODY_LIMIT

      BodyTooLarge, nothing sent

      The 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) and step_up_options() → AuthorizationOptions { max_age: Some(STEP_UP_MAX_AGE), prompt_login: false }. Kanidm honours max_age.

    • The margin: the relying party admits an auth_time within max_age plus LEEWAY_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. A const assertion holds STEP_UP_MAX_AGE.as_secs() plus LEEWAY_SECS.unsigned_abs() (by checked_add) under SECURITY_ADMIN_MAX_AGE_SECONDS.unsigned_abs(); all three live in canopy-auth.

    • The flow: on StepUpRequired, canopy-web (at the switch) authorizes with step_up_options() (relying_party().authorization(redirect, &options), the pending authorization carrying max_age), runs complete_sign_in, and opens a new outbound over the new session. D6 holds: the new id_token opens a session carrying the new auth_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 within UPSTREAM_LOGOUT_TIMEOUT, as sign_out does. 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 finds SignedOut also 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 a Superseded record (engine/leader.rs no_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 are String, so it formats its subject_id UUIDs and passes its upstream_sub as text. It keeps its own transport: a fixed stepped-up bearer and a Retry-After loop. Its upstream_issuer() becomes pub for 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.

  1. 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.

  2. 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 in lib.rs.

    • canopy-security: identity/admin.rs, admin/reads.rs and admin/writes.rs use the shared types and checks. Their rows convert with From, and ADMIN_PATH and ADMIN_BODY_LIMIT are 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.rs and services/canopy-security/src/identity/admin/tests.rs.

    • Tests:

      • each type serializes to today’s field names, with null for 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::parse accepts 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.

  3. U3 (#2831, w5) feat(auth): add the security-admin client (Y3, Y4).

    • Files:

      • identity_admin/client.rs (+ tests.rs);

      • identity_settings.rs's admin_url field and getter;

      • WebOutbound::remaining() made pub(crate);

      • identity_web_session/engine/sign.rs's supersede and Replaced (+ 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_age parsed, 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_age or the 600 s fallback without panicking, and a well-formed max_age=N gives N;

      • an error body with no code or not JSON (a plain-text 400, an empty 404, an ingress 503) gives None, never Malformed;

      • 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, rejected ran, and the first 401’s code picks the variant;

      • 403 is final;

      • the bound is the lesser of ADMIN_CALL_TIMEOUT and the deadline;

      • a malformed success;

      • admin_url().path() == ADMIN_PATH;

      • a maximal quote-filled LinkBody is BodyTooLarge with no request sent, and a body of exactly ADMIN_BODY_LIMIT bytes is sent;

      • step_up_options(), and the compile-time check;

      • supersede:

        • it ends the record as Superseded and 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.

  4. 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 repeats web_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’s LINKING_ADMIN) signs in with step_up_options() (broker.upstream_sign_in, then authorization(&redirect, &step_up_options())). It reads keys, clients and 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 id link_cast links, asserts it is not sec.admin's own, and suspends and lifts it (Recorded, changed);

      • jane.qc signs in and is Forbidden.

    • The per-IP limit, 60 a minute, is shared with link_cast and the broker’s tests, whose loop retries every second. Every admin call in the file therefore goes through a test helper, admitted. On Limited it waits 1 s and tries again, within a 120 s budget (the broker’s LIMIT_BUDGET). Each attempt runs over a fresh outbound (sender.calls with 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's link_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 whose target_subject is a cast realm id (= ANY($1), bound to canopy_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.adoc Added (and Changed for the move);

      • Amendment 20’s as-built record;

      • the plan Done and archived;

      • plan-lint --done with --allow-open for 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_time can pass 600 s mid-page, a step-up landing between calls. Each call answers StepUpRequired on 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:

  • the response ids became the SubjectId, SessionId and ActionId newtypes;

  • proptests for the challenge parser and the wire types' round-trips;

  • the skipped retry’s answer (rejected still runs; the first 401 is classified as a second).

  • Cut: the ADMIN_PATH re-export.

  • Notes folded in: the const assertion’s conversions; NewSubjectId's two refusals; remaining() as pub(crate); Limited without a field; the broker’s string fields and its upstream_issuer().

2

not stated (the maintainer’s other vendor)

not stated

3 findings (P2) and 2 (P3), fixed in-plan:

  • a step-up ends the replaced record through supersede, not sign_out;

  • devstack_identity_test's count is scoped to the cast’s realm ids;

  • U4’s bounded admitted loop over fresh outbounds;

  • a step-up is recognized from the challenge header alone;

  • the serialized body is checked against ADMIN_BODY_LIMIT.

Edit this page · default