Identity plane split, plan I2c: subjects and web sessions (epic &132)
- Context
- Scope
- Design
- Decisions (recorded in ADR-049 Amendment 6, which lands with U1; F4 fixes the web session’s end, which D3 needs and only D7’s native sessions have; F5 narrows C9’s Invalid class; F6 specifies how D6’s grace is recorded and extends C9’s grace to an unavailable key fetch)
- U1: session and subject primitives (canopy-auth)
- U2: the upstream changes renewal needs (canopy-auth)
- U3: session rows in the issuance log (canopy-security)
- U4: the subject and session stores (canopy-security)
- U5: the federation grant: open (canopy-security)
- U6: renewal and grace (canopy-security)
- U7: revocation by the opener (canopy-security)
- U8: the Kanidm lane’s proof (canopy-test-lib)
- Conventions every unit follows
- Units
- Verification
- Review log
Status: Done (2026-10-05) — !1571
Epic: &132 (stage I2 of &130)
Issues: #2712 (w3), #2713 (w5), #2714 (w3), #2715 (w5), #2716 (w5), #2717 (w5), #2718 (w2), #2719 (w3)
MR: feat/identity-federation-sessions: U1–U8 in order, titled "canopy-identity federation grant, subjects and web sessions (#2712 … #2719)".
The eight issues are one deliverable, the federation half of the user plane that I2d’s delegation mint reads, 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 (Status In progress) and its nav entry: a new group, Identity Plane Split (epic &130), holding * Identity plane split, plan I2c — subjects and web sessions (epic &132), placed just above ** Completed Plans Archive in docs/modules/ROOT/nav.adoc, as plans I2a and I2b 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 D6 has canopy-web present a verified upstream id_token to canopy-identity’s RFC 8693 federation grant, authenticated with private_key_jwt; canopy-identity validates it again, calls userinfo bound to its sub where the profile says, projects, links or mints the subject (D8), checks suspension (D12) and opens a session. D3 makes a session opaque, client-bound, stored hashed and never a JWT; D5 checks it by hash, only from its opener, unrevoked and fresh. D6 has canopy-web re-federate after each upstream refresh and at least every 900 s, refuses minting from a session last validated upstream more than 900 s plus a grace ago, caps grace at 30 min (60 min in code) and audits it. Amendment 2 narrows grace on the refresh path; Amendment 5 (C7–C9) narrows the id_token rules and gives an unavailable userinfo D6’s original grace.
In the tree today:
-
services/canopy-security/src/identity/token_endpoint.rsserves onlyclient_credentials;issuefixes one deadline before the form is parsed andaudit_deadlineclips the audit to request start +REQUEST_BUDGET(5 s); the form cap (token_endpoint/request.rs,MAX_FORM_BYTES, 16 KiB) is smaller than an upstream id_token plus an assertion; the 2 sPROCESSING_BUDGETis shorter than a cold discovery, JWKS and userinfo path (2.5 s each,crates/canopy-auth/src/upstream/client.rs). -
services/canopy-security/src/main.rsloads the upstream profile and builds_identity_upstream_client, unused: "plan I2c’s federation grant is their first reader". No key source, validator or userinfo client is built. -
crates/canopy-auth/src/upstream/(I2b) verifies an id_token (UpstreamIdTokenValidator), calls userinfo (UpstreamUserinfo: Unavailable, Refused, Invalid) and projects (project→FederatedIdentity).VerifiedUpstreamIdTokenexposes noiat;NumericDatehas no public constructor;projecttakes only a validator-builtUpstreamAnchor, so a userinfo renewal cannot project; the profile parses everyclaims_from×refreshpairing.crates/canopy-auth/src/key_cache.rsstamps a fetch attempt before awaiting it, so a cancelled fetch debounces lookups for 30 s, and both the validator’s key lookup and userinfo’s endpoint lookup can start one. -
crates/canopy-auth/src/identity_policy/delegation.rsdefinesSubjectIdandSessionId(any UUID version) without a mint,DisplayorFromStr. -
The issuer login (
identity/registry.rs,identity/probe.rs) holds INSERT and SELECT, plus EXECUTE on its jti purge; the probe refuses any UPDATE, DELETE or TRUNCATE grant.identity_issuance_log(migration20261210000000) requires akidandtoken_jtion every issued row, has no subject or session column, and digeststo_jsonb(NEW). -
No subject, link, session or suspension table exists.
worker_directoryis keyed on the upstream(issuer, subject); ADR-046’s banner moves it to the canopy subject at I3.
Scope
In scope: U1–U8 below: the session and subject primitives, the upstream changes renewal needs, the issuance log’s session rows, the subject and session stores, the federation grant, renewal with grace, revocation by the opener, and the Kanidm lane’s proof.
Out of scope:
-
canopy-web calling the grant, its nonce and
max_age, its client key, the directory re-key, seed links and theworker_directoryroutes (I3); -
the delegation mint and its freshness check, and rate limits keyed by client (I2d; capacity is I2g’s);
-
security-admin routes: suspending and lifting a subject, revoking any session, re-linking a subject, runtime client disablement, and step-up enforcement (I2e);
-
native sessions, the device grant and DPoP (I2f).
Design
Decisions (recorded in ADR-049 Amendment 6, which lands with U1; F4 fixes the web session’s end, which D3 needs and only D7’s native sessions have; F5 narrows C9’s Invalid class; F6 specifies how D6’s grace is recorded and extends C9’s grace to an unavailable key fetch)
| # | Decision |
|---|---|
F1 |
The grant’s wire shape.
|
F2 |
The answer. RFC 8693 §2.2.1: |
F3 |
Sessions. The credential is 32 CSPRNG bytes, canonical unpadded base64url, stored only as its SHA-256. A session is INSERT-only records owned by |
F4 |
Session terms. |
F5 |
Renewal. A session is bound to the upstream issuer and client it opened under: a renewal under a profile whose |
F6 |
Grace. A renewal records grace when canopy-web declares |
F7 |
Subjects. A subject is a UUID v7 minted on the first successful open of an unseen ( |
F8 |
Suspension and revocation. I2c builds the suspension record (INSERT-only, latest wins) and checks it at open and renewal; its writer functions are granted to nobody, as |
F9 |
Profile pairing and deadlines. |
U1: session and subject primitives (canopy-auth)
-
identity_policy/delegation.rs:SubjectId::mint()andSessionId::mint()(UUID v7),DisplayandFromStr, keeping any-version parsing. -
New
crates/canopy-auth/src/identity_session.rs:-
SessionCredential:mint(),parse(&str)(exactly 43 canonical base64url characters),hash() → SessionCredentialHash(SHA-256); zeroized, noDebug,DisplayorSerialize(compile-time probes asSubjectBearerhas); -
F1 and F2’s wire constants (
TOKEN_EXCHANGE_GRANT,ID_TOKEN_TYPE,WEB_SESSION_TOKEN_TYPE, theupstream_*parameter names,NOT_PROCESSED) and the closedCanopyRefusalwithcode(); -
F4 and F6’s terms as pure functions of injected times:
SessionTerms::open(auth_time, validated_at, now, &SessionLimits) → Result<SessionTerms, OpenRefusal>,fresh_until(validated_at, ends_at),grace_until(last_success, ends_at, &SessionLimits);SessionLimits::newrefuses either setting outside F4’s and F6’s bounds; -
F9’s deadline constants, compile-asserted.
-
-
Tests: credential round trip, an evil-input table (padding,
+//, 42 and 44 characters, non-canonical trailing bits, non-ASCII) and a proptest thatparseaccepts exactly whatmintrenders; each term at its boundary (899/900 s, the bounds, grace never past the end); the ids' v7 mint and any-version parse. -
Docs: ADR-049 Amendment 6 (F1–F9) with its Status line; an
identity_sessionbullet under== canopy-authinshared-crates.adoc, afterupstream; this page and its nav entry.
Erratum (2026-10-05): TOKEN_EXCHANGE_GRANT re-exports the existing canopy_auth::discovery::TOKEN_EXCHANGE_GRANT.
Erratum (2026-10-05): SessionTerms::open also refuses OpenRefusal::EndOutOfRange when auth_time plus the maximum passes the last NumericDate (unreachable from a validated id_token); U5 answers it invalid_request.
Erratum (2026-10-05): the session terms take and give whole-second NumericDates, with now a chrono::DateTime<Utc> judged in whole seconds, as the id_token validator judges it; F4’s "under 900 s" is read against that now.
U2: the upstream changes renewal needs (canopy-auth)
-
upstream/id_token.rs:VerifiedUpstreamIdToken::issued_at() → NumericDate(NumericDate::from_seconds(i64)landed in U1). -
upstream/projection.rs:projecttakes aProjectionAnchor(iss,sub,auth_time), builtFrom<&UpstreamAnchor>orFrom<&StoredAnchor>. -
New
upstream/renewal.rs:-
StoredAnchor::new(iss, client, sub, auth_time, nonce_digest: Option<[u8; 32]>, last_iat: Option<NumericDate>, last_digest: Option<[u8; 32]>), built by canopy-security from its own store;StoredAnchor::bound_to(&UpstreamProfile) → Result<(), BindingMismatch>checks F5’s issuer and client binding; -
check_refreshed(&StoredAnchor, &VerifiedUpstreamIdToken, presented_digest) → Result<Refreshed, RefreshMismatch>: F5’s match;Refreshed::{Newer, Replay};RefreshMismatchnames the rule, never a value; -
RenewalVerdict::{Revoke(RevokeReason), Grace, Lapse(LapseReason)}withclassify_userinfo(&UpstreamUserinfoError),classify_keys_unavailable(),classify_projection(&ProjectionRefusal),classify_mismatch(&RefreshMismatch)andclassify_binding(&BindingMismatch), F5 and F6’s table.
-
-
upstream/profile.rs: F9’s pairing rule, refused asInvalid { field: "refresh", fault: UpstreamFieldFault::MixedSources }.upstream/userinfo.rs:MAX_UPSTREAM_ACCESS_TOKEN_BYTES= 8 KiB, refused asInvalid::AccessTokenbefore any request. -
key_cache.rs: a refresh runs its fetch in a task the cache spawns and owns; callers await the task’s result, so dropping a caller never cancels the fetch or leaves the debounce stamped without a result. This coversUpstreamKeySource(keys and userinfo’s endpoint) and I1b’sHttpJwksKeySourcealike. -
Tests: each
RefreshMismatchandBindingMismatchalone;ReplayvsNotNewerat an equaliat; the four nonce pairs; a stored anchor projecting as the validator-built one does; every outcome’s verdict; both mixed pairings refused; the access-token cap; a cold-cache lookup dropped mid-fetch (by a key lookup and by userinfo’s endpoint lookup) after which the fetch completes and the next lookup is served without a debounce. -
Docs: the
upstreambullet inshared-crates.adoc;configuration-reference.adoc's[#identity-upstream]gains the pairing rule.
Erratum (2026-10-05): U1 adds NumericDate::from_seconds, which U2 named, because U1’s session terms build NumericDates; U2’s section is corrected to as-built.
Erratum (2026-10-05): ProjectionAnchor and FederatedIdentity hold the upstream issuer as written (FederatedIdentity::iss() → &str), since a StoredAnchor's issuer is its store’s text and UpstreamIssuer has no public constructor; StoredAnchor::new takes iss and client as String and sub as OidcSubject.
Erratum (2026-10-05): U2 also exports upstream::nonce_digest and upstream::id_token_digest (SHA-256 of the nonce’s bytes and of the compact id_token as presented), which U4 and U5 store and check_refreshed compares.
Erratum (2026-10-05): check_refreshed refuses a session with no recorded id_token iat as NotNewer and finds no replay without a recorded digest.
Erratum (2026-10-05): U2 adds a sixth classifier, classify_id_token, so a refused refreshed id_token lapses and an unavailable key fetch grants grace through the same exhaustive table; the upstream anchors' Debug output omits the upstream sub and nonce.
U3: session rows in the issuance log (canopy-security)
-
Migration
services/canopy-security/migrations/20261213000000_identity_issuance_log_v2.sqladdsgrant_type IN ('client_credentials','token_exchange','revocation'),subject_id UUID,session_id UUID,session_event IN ('opened','renewed','grace','replayed','superseded','revoked'), and widensoutcometoissued,refused,revoked,ignored. Version 1 rows stay valid as history; aNOT VALIDCHECK makes every new row version 2, under this table:grant_type outcome session_event requires client_credentials
issued
none
token_jti,kid,expires_atclient_credentials
refused
none
errortoken_exchange
issued
opened, renewed, grace, replayed, superseded
session_id,subject_id,expires_at=fresh_until; nokidortoken_jtitoken_exchange
refused
none, or revoked
error;subject_idandsession_idwhen known; revoked needs bothrevocation
revoked
revoked
session_id,subject_idrevocation
refused
none
error: any ofinvalid_request,invalid_client,unauthorized_client,temporarily_unavailablerevocation
ignored
none
nothing else (an unknown, ended or revoked credential, answered 200)
-
The stamp trigger digests version 2 rows over every column;
data-models/canopy-security.adocdocuments each version’s digest recompute.IssuanceRecordand the batch insert carry the new columns, and alog_in(&mut PgConnection, &IssuanceRecord)inserts one row inside a caller’s transaction for U4’s state changes; refusals keep the group-commit writer. The registry tests that insert version 1 rows move to version 2. -
No upstream
sub, username, token or credential is logged. -
Tests: every row of the table, and each refused
error, as CHECK cases; theNOT VALIDrefusal of a new version 1 row; each version’s digest; a mixed-grant batch;log_inrolled back with its transaction. -
Docs:
[#identity-issuance-stores]indata-models/canopy-security.adoc.
Erratum (2026-10-05): U3’s table gains a row: no grant_type | refused | none | error, for a token request refused before its grant type was established; the token endpoint records the grant once grant_type has passed its check, including for a later missing-parameter or assertion-type refusal.
Erratum (2026-10-05): a refused revocation carries subject_id and session_id together when known; on a refused token exchange, session_id appears only with subject_id.
U4: the subject and session stores (canopy-security)
-
Migration
20261214000000_identity_subjects_sessions.sql, following20261210000000(owner transfer, REVOKE ALL, column grants, a closing audit over every identity object):-
identity_subjects (subject_id UUID PK, created_at);identity_subject_links (upstream_iss, upstream_sub, subject_id REFERENCES identity_subjects, linked_at)withUNIQUE (upstream_iss, upstream_sub),UNIQUE (subject_id, upstream_iss),upstream_subchecked toOidcSubject's shape; -
identity_subject_suspensions (event_id UUID PK, subject_id, suspended BOOLEAN, recorded_at, actor TEXT, reason TEXT),actorandreason1–200 bytes; -
identity_sessions (session_id UUID PK, credential_hash BYTEA UNIQUE, kind, client, subject_id, upstream_iss, upstream_client, upstream_sub, auth_time, nonce_digest BYTEA NULL, opened_at, ends_at): digests 32 bytes;kind = 'web'withclient = 'canopy-web';opened_at < ends_at ⇐ auth_time + interval '86400 seconds'; -
identity_session_validations (validation_id UUID PK, session_id, version BIGINT, recorded_at DEFAULT clock_timestamp(), kind IN ('open','renewal','grace'), validated_at, id_token_iat NULL, id_token_digest BYTEA NULL, fresh_until, roles TEXT[], programs TEXT[], username TEXT):UNIQUE (session_id, version),version >= 1,(kind = 'open') = (version = 1); the iat and digest both present or both absent, absent on grace rows;fresh_until ⇐ validated_at + interval '4500 seconds'; -
identity_session_revocations (session_id UUID PK, revoked_at DEFAULT clock_timestamp(), reason IN ('logout','upstream_refused','projection_refused','upstream_changed','suspended'), client); -
owner functions,
SECURITY DEFINER, issuer EXECUTE (the issuer holds no INSERT on these tables):-
identity_link_or_mint_subject(p_iss text, p_sub text, p_candidate uuid) RETURNS uuid; -
identity_open_session(…), inserting the session (every column above) and its version 1 validation; -
identity_record_session_renewal(p_session uuid, p_expected_version bigint, p_validation uuid, p_validated_at timestamptz, p_id_token_iat timestamptz, p_id_token_digest bytea, p_fresh_until timestamptz, p_roles text[], p_programs text[], p_username text, p_now timestamptz) RETURNS text: locks the session row, then answers in orderrevoked;ended(p_now >= ends_at);replayed(digest equal to the latest id_token row’s);not_newer(iatnot after it);superseded(latest version ≠p_expected_version); else inserts version + 1 and answersrecorded; -
identity_record_session_grace(p_session uuid, p_expected_version bigint, p_validation uuid, p_grace_seconds integer, p_now timestamptz) RETURNS text: locks the row, answersrevoked,ended,superseded, orexhausted(F6’sfresh_untilnot afterp_now), else copies the latest successful row’s instant, roles, programs and username, inserts version + 1 and answersrecorded; -
identity_revoke_session(p_session uuid, p_reason text, p_client text) RETURNS boolean, false when a revocation exists; -
identity_purge_sessions(p_batch integer), deleting sessions ended or revoked over 30 days ago with their rows;
-
-
owner functions granted to nobody:
identity_suspend_subject(p_subject uuid, p_actor text, p_reason text)andidentity_lift_subject_suspension(p_subject uuid, p_actor text, p_reason text).
-
-
identity/registry.rsandidentity/probe.rstake the new tables and functions into the grant matrix.ISSUER_POOL_MAX_CONNECTIONSrises from 8 to 13, its doc table gaining four connections for federation’s transactions (none held across an upstream call) and one for the session purge. -
New
identity/sessions.rs: anIdentitySessionstrait with a Pg implementation on the issuer pool, asJtiStoreis. Each write is one composite operation that owns its whole transaction and commits its U3 log row inside it:-
open(OpenRecord) → OpenOutcome: link-or-mint, the subject’s suspension,identity_open_session, theopenedrow; a suspended subject rolls back and answersSuspended; -
renew(RenewRecord) → RenewOutcomeandgrace(GraceRecord) → GraceOutcome: the suspension (a hit revokessuspendedand commits therevokedrow), then the function, then the row for its answer; -
revoke(RevokeRecord) → bool, with its row; -
current(hash, client) → Option<SessionState>, a read: F2’s fields plus the version, the revocation and the stored anchor.
-
-
A new
identity/sessions/sweeper.rstask calls the purge beside the jti sweeper. -
SecurityConfiggainsidentity_web_session_max_secondsandidentity_session_grace_seconds, refused at boot throughSessionLimits::new. -
Tests (
tests/identity_session_store_test.rs, EphemeralSchema as the issuer login): every CHECK; link-or-mint racing on two pools to one subject; each function’s answers; two userinfo renewals interleaved so the broader one reads first and commits last, answeringsupersededand leaving the narrower one latest; a grace racing a narrowing renewal never re-widening; versions ordered by allocation when two rows share arecorded_at; a failed log row leaving no subject, session, renewal or grace; the issuer refused direct INSERT, UPDATE and DELETE and the nobody-granted functions; the probe accepting the new matrix and refusing a widened grant; the purge’s age and batch bounds. -
Docs:
data-models/canopy-security.adocgains[#identity-subjects-sessions]after[#identity-issuance-stores];configuration-reference.adocgains both settings;security-operations.adoc[#identity-registry]gains the new grants, the purge, and suspending a subject as the owner until I2e.
Erratum (2026-10-05): every IdentitySessions operation takes the caller’s deadline, detaching its connection past it.
Erratum (2026-10-05): suspension events carry a per-subject version allocated under the subject’s row lock; the latest is the highest version.
Erratum (2026-10-05): a session’s fresh_until is its highest version’s, a grace’s included; roles, programs and username are the latest successful validation’s, which a grace copies.
Erratum (2026-10-05): UpstreamUsername::parse is public, for the session store’s read-back; the issuer-login test fixtures live in tests/common/issuer.rs.
Erratum (2026-10-05): the store judges a session by its stored subject, and the owner functions guard inputs their store never sends.
Erratum (2026-10-05): the open, renewal and grace functions read the subject’s suspension under a key-share lock on the subject row and answer suspended, so a suspension committed during an operation is never missed.
Erratum (2026-10-05): the open, renewal, grace and link-or-mint functions refuse any isolation level but READ COMMITTED (25000), and the store begins every transaction at READ COMMITTED.
U5: the federation grant: open (canopy-security)
-
token_endpoint/request.rs:TokenRequestbecomes per-grant (ClientCredentials|TokenExchange), F1’s grammar and caps,MAX_FORM_BYTES64 KiB. -
main.rsbuildsUpstreamKeySource,UpstreamIdTokenValidatorandUpstreamUserinfofrom the profile and oneUpstreamHttpClient(no request at boot, D2) and passes them, asOption, intoTokenEndpoint::new. -
token_endpoint.rs:issuereads and authenticates within F9’s first phase; a token exchange then runs to F9’s absolute deadline, andaudit_deadlinetakes that deadline instead ofREQUEST_BUDGET. An open runs: Web only; validate the id_token; userinfo withexpected_sub= the anchor’ssubwhen the claims come from userinfo; project;SessionTerms::open;IdentitySessions::open; F2’s body. A refusal is logged before the answer, as today.TokenErrorCodegainsunauthorized_client; metadata lists the grant when a profile is configured. -
Tests (
tests/identity_federation_test.rs, EphemeralSchema plusmock_issuer, a registry holding a test canopy-web key): an open per profile kind; every refusal (client, each grammar defect, each C7 class, keys unavailable, each userinfo outcome, each projection code,auth_time_too_old, suspended); nothing left by a refusal; nothing released without its log row; an upstream refusal arriving at 7.4 s still logged before the deadline; a form at every cap at once with the access token fully percent-encoded; an evil-input table of forms (duplicates, both forms mixed, oversized decoded values, percent-encoded control characters) and a proptest that no form panics the parser. -
Docs:
api/canopy-security.adoc(the token endpoint’s grants, body,canopy_refusal, error table);idp-integration.adocgains[#federation-grant]after[#upstream-profile];configuration-reference.adoc's[#identity-upstream]no longer says nothing reads the profile;security.adocno longer says the endpoint grants only client credentials;authorization-inventory.adocandservices.adocgain the grant.
Erratum (2026-10-05): the body is read within the 2 s processing budget before the grant is known; a token exchange’s client is authenticated by the first phase’s 2.5 s, and its exchange parameters are judged after the client and profile checks.
Erratum (2026-10-05): both grants recognize every parameter either reads, so a repeated or control-bearing token-exchange parameter also refuses a client-credentials form (RFC 6749 §3.2).
Erratum (2026-10-05): main.rs passes the upstream parts as one Option<Federation> (profile, key source, validator, userinfo client, session store, limits); canopy-security gains the workspace dependency zeroize for the access token userinfo takes.
Erratum (2026-10-05): no valid assertion reaches 8 KiB (its claims are closed and its jti is at most 128 characters), so the every-cap form is read whole to invalid_client, and an open at the id_token’s and access token’s caps is tested separately; the grammar’s 16 KiB cap refuses an oversized id_token before the validator’s own cap, which is mapped and unit-tested.
Erratum (2026-10-05): F5’s classification holds at open too: a presentation defect is invalid_request and a deployment defect 503 temporarily_unavailable, neither with a canopy_refusal; upstream_refused names only the upstream’s own verdicts.
Erratum (2026-10-05): the late-refusal test scripts three 2.4 s upstream delays, so the refusal arrives at 7.2 s or later, past the client-credentials budget, with 100 ms of margin under the client’s 2.5 s timeout.
Erratum (2026-10-05): the session transaction takes the deadline less 1.5 s (TOKEN_EXCHANGE_TRANSACTION_END, 11.5 s from the start), so a transaction that never answers is still refused with its log row before the deadline; the reserve’s last 1.5 s are the refusal’s.
U6: renewal and grace (canopy-security)
-
The renew form:
currentby hash and opener (session_endedif none), within F9’s first phase;StoredAnchor::bound_tothe profile (a mismatch revokesupstream_changed); then by the evidence:check_refreshedand re-project the refreshed id_token; or userinfo bound to the storedsub, projected throughProjectionAnchor::from(&StoredAnchor); or grace. Act onRenewalVerdict; record throughreneworgracewith the versioncurrentread; answer F2’s body, or the current state for a replay or a superseded renewal. -
Tests (in
tests/identity_federation_test.rs): renewal per profile; the profile’s issuer changed and its client changed, each revoking with no upstream call; eachRefreshMismatchrefused with the session intact; a replay answering the same state; a superseded renewal answering the newer state; userinfo Refused and upstream Invalid revoking,AccessTokenandNoEndpointlapsing; a refusal after a grace leaving the grace’sfresh_until; Unavailable, keys unavailable andnot_processedgranting grace;grace_exhausted; roles widening and narrowing; a stalled session read refused within the first phase and logged; a cold-cache userinfo renewal dropped mid-discovery, after which the fetch completes.
Erratum (2026-10-05): U6’s database tests live in tests/identity_federation/renewal.rs, a #[path] module of the identity_federation_test binary.
Erratum (2026-10-05): a replayed id_token is verified, matched and projected as a newer one is, and recorded through renew, which answers replayed under the session’s lock; a replay whose claims no longer project revokes.
Erratum (2026-10-05): the renew grammar refuses a malformed credential (session_credential_malformed) and an upstream_outcome other than not_processed (upstream_outcome_unsupported), each invalid_request with no canopy_refusal; ExchangeParameters::form takes the profile’s claims_from and refresh.
Erratum (2026-10-05): a changed binding’s refused revoked row names the field (upstream_issuer_changed, upstream_client_changed); the stored revocation reason is upstream_changed. A refreshed id_token from another issuer is refused by C7 before the refresh rules, RefreshMismatch::Issuer staying as defence in depth.
Erratum (2026-10-05): a renewal’s revocation, renewal and grace each run by the transaction end; a refusal whose row the store committed with its revocation is answered without a second row.
U7: revocation by the opener (canopy-security)
-
POST /identity/revoke(RFC 7009) on the token endpoint’s router and limiter,private_key_jwt: a client other than canopy-web isunauthorized_clientbefore any lookup; canopy-web’s request for its live session revokes it (logout) and answers 200; an unknown, ended or revoked credential answers 200 and revokes nothing.token_type_hintis ignored, as RFC 7009 permits. A malformed form isinvalid_request, a bad or spent assertioninvalid_client, an unavailable storetemporarily_unavailable, each logged per U3’s table.IssuerConfiggainsrevocation_endpointand its internal twin; metadata gainsrevocation_endpoint,revocation_endpoint_auth_methods_supported: ["private_key_jwt"]andrevocation_endpoint_auth_signing_alg_values_supported: ["ES256"](RFC 8414 §2). -
Tests: each outcome and its log row, every refused
error, an idempotent repeat, a revoked session refused at renewal, the metadata fields resolving to the route, an evil-input form table. -
Docs:
api/canopy-security.adoc,authorization-inventory.adocandservices.adocgain the route.
Erratum (2026-10-05): TokenEndpoint::new takes the session store beside Federation's, so the revocation endpoint is served, and the metadata lists it, with or without an upstream profile, since a session outlives its profile; main.rs passes one store to both.
Erratum (2026-10-05): a revocation runs under the client-credentials budget: the body, authentication, session read and revocation (with its revoked row) by 2 s, and an ignored or refused row within 5 s; its 200 carries no body (RFC 7009 §2.2).
Erratum (2026-10-05): the revocation form uses the token form’s read_body and scan and its 64 KiB cap; token_type_hint is recognized, so a repeated or control-bearing one is refused, and its value is ignored. U7 adds canopy_identity_revocation_answers_total{answer}.
U8: the Kanidm lane’s proof (canopy-test-lib)
-
crates/canopy-test-lib/tests/idp_conformance_kanidm.rsruns U1’s and U2’s rules on real tokens (the grant itself needs canopy-security and a database, so U5 and U6 prove it in-process):SessionTerms::openon a fresh sign-in;check_refreshedansweringNewerfor a real refreshed id_token (refreshed aftersleep_until_early_in_next_second, since Kanidm stamps whole seconds),Replayfor the same token again, andNotNewerfor the original once the stored anchor has advanced; a stored anchor projecting a real userinfo answer as the id_token did; the expired person’s userinfoRefusedclassifiedRevoke. The module doc’s one-job list names these readers. -
ADR-050 Amendment 4, a run record in Amendment 3’s style, stating which session properties the lane proved and which only in-process.
-
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; andcargo xtask plan-lint --done docs/modules/ROOT/pages/plans/archive/identity-plane-split-i2c.adoc --allow-open 2712 --allow-open 2713 --allow-open 2714 --allow-open 2715 --allow-open 2716 --allow-open 2717 --allow-open 2718 --allow-open 2719.
Conventions every unit follows
-
Every parser has an evil-input table and a proptest (the credential, the token-exchange form, the revocation form); the id_tokens keep I2b’s
jws_evil_cases!. Errors are thiserror enums that never echo input; logs carry canopy subject and session ids, never an upstreamsub, username, token or credential. -
Nothing calls the upstream at boot. Tests inject
nowand never sleep, except the real-IdP lane, which waits for Kanidm’s whole-second clock through its existing helpers. Database tests live intests/or aninfra_testsmodule. -
Every
serde_json::Valueundersrc/carries// PARTNER-EDGE-UNTYPED:on the line before. -
Every unit ships its
CHANGELOG.adocbullet and the canonical page for the surface it changes.
Units
-
U1 (w3) —
feat(auth): mint canopy subjects, session ids and credentials (#2712). -
U2 (w5) —
feat(auth): check refreshed id_tokens, project stored anchors (#2713). -
U3 (w3) —
feat(security): log session events in the issuance log (#2714). -
U4 (w5) —
feat(security): store canopy subjects and web sessions (#2715). -
U5 (w5) —
feat(security): open a web session from an upstream id_token (#2716). -
U6 (w5) —
feat(security): renew web sessions under a bounded grace (#2717). -
U7 (w2) —
feat(security): let canopy-web revoke its own sessions (#2718). -
U8 (w3) —
test(identity): prove the session rules on the Kanidm lane (#2719).
Verification
-
Per unit: fmt; clippy in both profiles; nextest for canopy-auth, canopy-security and canopy-test-lib;
rustdoc-private;quality-budgets;feature-builds;http-clients audit-timeoutsandaudit-redirects;secret-loads;migrations-lintanddb-pools(U3, U4); the named database tests withCANOPY_TEST_INFRA=required. -
U8: two full
cargo xtask identity conformance --idp kanidmruns, reading the JUnit in full. -
Per MR: every
validatestage, thengit push(the pre-push battery), aftercargo xtask dev reloadbrings the migrations up on the devstack.
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-10-05) |
Anthropic |
claude-opus-5-5 |
no-ship. Eight blockers, all fixed: profile pairings that could never renew (now both sources must match); an unreachable replay (the digest joins the stored anchor); a grace row built from state read before the lock (the grace function copies under the lock); state changes that could take effect unlogged (each commits its log row); the log’s version 2 shape; the revocation endpoint revealing another opener’s credential; a lane assertion no unit built (the renewal verdict table); and the key-fetch cancellation claim. Also taken: C9’s Invalid narrowed to the upstream’s verdicts, the refreshed-nonce reading, typed answer fields, |
2 (2026-10-05) |
OpenAI |
gpt-6-astra |
no-ship. Ten findings and two gaps, all fixed: a session bound to its upstream issuer and client (a change revokes it); stale renewal results rejected by an expected version; validations ordered by a version allocated under the lock, not a wall clock; every revocation refusal loggable; composite store operations owning their transactions; a refusal after grace leaving the grace (the lapse promise corrected); one absolute deadline with an audit reserve; the issuance log moved ahead of the stores (a dependency cycle); RFC 8414’s revocation signing-algorithm field; a 64 KiB encoded form cap; fetches detached inside the key cache, covering userinfo’s discovery; the real-IdP lane’s whole-second waits. No round 3. |