Identity plane split, plan I3c: canopy-identity receivers (epic &133)
Status: Done (2026-10-09) — !1583
Epic: &133 (stage I3 of &130)
Issues: #2792 (U1, w2); #2793 (U2, w2); #2794 (U3, w3); #2795 (U4, w3); #2796 (U5, w3); #2797 (U6, w2); #2798 (U7, w2). Plan I3c2’s issue is #2799 (L7). Each unit relates to #1448, whose X-Canopy-Actor criterion L4 builds.
MR: feat/identity-receivers, "canopy-identity receivers (#2792 … #2798)".
One MR, one commit per issue, under the maintainer’s one-MR-per-related-group ruling: U7’s devstack proof exercises U2–U6 together. U1’s commit adds this page and its nav entry, and U7 closes it. The MR merges once the pre-push battery passes, the maintainer’s standing rule while CI is broken upstream. This is a Design + Scope plan: GitLab owns tracking, and the plan freezes when U1 starts. L1–L7 are this plan’s decisions (ADR-049 Amendment 14).
Context
ADR-049 Amendment 11 stages the cut-over. I3c is "receivers: an axum layer and principal around IdentityTokenValidator, the guard set replacing Claims and ReceiverContract, receiver settings; unwired" (plan I3a, The stage).
In the tree today:
-
The validator is
canopy_auth::IdentityTokenValidator(identity_token.rs), built for one compiledCanopyService.validate(token, request_start)returnsVerifiedBearer::{System, Delegation}and verifies once (G8).-
It checks a delegation token’s last hop with
may_delegate. -
It checks nothing equivalent for a system token.
-
-
The key source
HttpJwksKeySourceholds D9’s numbers through the sharedkey_cache.rs: refresh at 300 s, a 30 s debounce, fail-closed at 720 s.-
Refresh happens only on a lookup, and a lookup that finds a fetch due, or one in flight, waits for it.
-
So a hung canopy-security stalls every receiver for up to the 10 s fetch timeout, every 30 s, while its keys are trusted until 720 s.
-
The Keycloak path refreshes on a timer from boot (
jwks.rsstart_refresh_task).
-
-
No principal or generic layer exists. canopy-security’s admin-only
SecurityAdmin(identity/admin/guard.rs) is the precedent for the refusal shape. -
Today’s path has three parts:
AuthLayer+auth_middleware, insertingClaims,SubjectBearerandApplicantOwnership; each service’sReceiverContract+exchanged_gate; and about 20 bars onClaims,ReceiverContractandEffectiveUser, inside handlers. -
Many service-only routes are reached in a worker’s request on a service token. After the switch these calls carry delegation tokens: canopy-web’s edges and canopy-cli’s are delegation only, and B4 makes every in-request service call delegation. The round-2 inventory found about 50 canopy-web routes, 18 in-request service-to-service routes and 34 canopy-cli calls whose bars refuse a user (L7).
-
Settings. canopy-identity’s issuer settings exist only in canopy-security (
IssuerConfig, validated byidentity_url). Its config is partitioned againstServiceSettingsunderdeny_unknown_fields(#1773).
Decisions (ADR-049 Amendment 14, L1–L7; land with U1)
-
L1. The principal.
Principal::{User(UserPrincipal), System(SystemPrincipal)}, built fromVerifiedBearer.-
UserPrincipalholds theVerifiedDelegation, for plan I3d’s onward sender. It exposes the subject, session, roles, programs, actor chain, current actor,auth_time,jtiandexp, andoidc_subject() → Result<OidcSubject, ApiError>. -
SystemPrincipalholds theSystemTokenClaims. It exposes the client, purpose, scopes,jtiandexp. -
Principalexposes:-
user()andsystem()(Options); -
client() → Client: the system token’s client, or the current actor; -
has_role(role), false for a system caller; -
actor() → Result<Actor, ApiError>, forActorconsumers:Humanwith the canopy subject’s hyphenated form, which K8 keeps equal to the realm ids rows hold, orServicewith the client id; -
attribution_sub() → String, for the string consumers (idempotency keys, ledgers, export and FTI records): the canopy subject, or a system token’ssub, which is its client id (A4). Today a service’s value is its Keycloak service-accountsub.
-
-
Programs are carried but not enforced.
-
-
L2. One composable guard:
Admission.principal.admit(&admission) → Result<(), ApiError>.-
Construction. An
Admissionisconst-constructible and never empty. It starts from one arm and adds others:-
starts:
Admission::system(),::system_from(&[ConfidentialClient]),::portal(scope),::user_roles(roles)and::user_roles_via(&[Client], roles); -
additions:
.and_system(),.and_portal(scope),.and_user_roles(roles)and.and_user_roles_via(..).
-
-
The arms:
-
system: any confidential client but the portal, or the listed ones. L3 has already held it to an edge.
-
portal: canopy-portal’s system token, holding the scope.
-
user: a delegation token holding a listed role, from any actor G8 admits.
-
user via: the same, only when its current actor is listed. It is the arm for a route a service reaches inside a worker’s request: it carries the user without opening the route to every delegation caller.
-
-
Refusals (403,
ReceiverDenial), in order:-
A portal caller: no portal arm →
portal_on_non_portal_route; no scope →portal_scope_missing. -
A system caller: no system arm →
service_class_on_user_onlyif a user arm exists, elseportal_only_route; not insystem_from→service_not_allowlisted. -
A user: no user arm →
system_caller_requiredif a system arm exists, elseportal_only_route. An actor that no user arm admits →actor_not_allowed. An admitted actor holding none of the roles →required_role_missing.Every code is today’s except
system_caller_requiredandactor_not_allowed.
-
-
Ownership stays a step after admission:
require_owned_{application,household,person}(ownership, id). Only the portal needs a binding claim (D11).
-
-
L3. A system token’s edge. The validator refuses a system token whose client has no
SystemorBothedge to the receiver (may_hold_system_token), withRejection::SystemEdge, checked last. This is the system counterpart of D4’s last-hop re-check. Purposes and scopes stay the issuer’s. -
L4. The layer.
IdentityReceiver(state) andidentity_receiver_middleware(axumfrom_fn_with_state) insert aPrincipal. In order:-
The bearer: exactly one
Authorizationheader, schemeBearercompared case-insensitively, and one non-empty token (RFC 6750 §2.1). -
X-Canopy-Actoris refused, before any key lookup. -
Validation at the wall clock (D14), within
RECEIVER_KEY_BUDGET(2 s). -
X-Canopy-Applicant: for the portal only, verified through the existingApplicantClaimVerifier, and inserted asApplicantOwnership.401 is only for a token, always with its RFC 9110 §15.5.2 challenge:
Condition Answer WWW-AuthenticateNo usable bearer
401
token_missingBearerX-Canopy-Actorpresent400
actor_header_retired(RFC 6750 §3.1invalid_request)—
Rejected by the validator
401
token_rejectedBearer error="invalid_token"Keys unavailable, or the budget passed
503
keys_unavailable—
Applicant claim from a non-portal caller
403
applicant_claim_not_portal—
Applicant claim, no verifier configured
403
applicant_claim_unverifiable—
Applicant claim invalid
403
applicant_claim_invalid—
A refusal logs its validator rule at
info, never the token.
-
-
L5. A receiver’s keys refresh on a timer, and wait only without evidence of an outage.
HttpJwksKeySource::start_refresher(&self) → boolspawns a task.-
Each tick is 30 s (
FETCH_DEBOUNCE) apart, the first at once. It stamps the cache’srefresher_tick(monotonic). It starts a fetch, through the single flight and debounce, when no set is held or the set is at leastREFRESH_AHEAD(240 s) old. -
The task holds the cache weakly and ends when it is dropped. A drop guard owned by the task clears
refresher_tickwhen the task ends for any reason: abort, runtime shutdown or panic. It clears only its own generation’s tick. -
Starting.
start_refresherdoes nothing while a refresher is live (ticked withinREFRESHER_LIVE, 60 s), and sets nothing when there is no runtime to spawn on. -
The cache records each completed fetch’s outcome.
-
The no-wait rule. A lookup answers from a set aged 300–720 s that holds the kid without waiting only while the refresher is live and the latest completed fetch failed. Otherwise today’s rule holds: a fresh set answers, a stale one fetches and waits. The upstream key source (C5) starts no refresher, so it is unaffected.
-
Bounds.
-
While the JWKS answers, the refresher’s fetch lands before the set reaches 280 s. So a revoked key stops verifying within 300 s, idle or busy.
-
While it fails, the bound is 720 s.
-
A refresher that dies, cleared or not, stops granting no-wait within 60 s.
-
These are D9’s bounds as stated.
-
-
-
L6. Receiver settings are a typed value now;
ServiceSettingsfields come at the switch.-
Shared URL rules.
identity_url,IDENTITY_PATHandIdentityUrlErrormove to canopy-auth (identity_url.rs). canopy-security’sconfig.rscalls them and re-exportsIDENTITY_PATH. A 1:1From<IdentityUrlError> for IssuerConfigErrorkeeps its error type, messages, importers and tests. -
ReceiverSettings::new(issuer, internal_url, development)(identity_receiver/settings.rs) validates both by those rules and derivesjwks_uri. Its errors nameidentity_issuerandidentity_internal_url, the names I3g gives theServiceSettingsfields (CANOPY_<SVC>__IDENTITY_ISSUER,__IDENTITY_INTERNAL_URL); canopy-security mirrors them then, as it mirrorsrulesets_dir. -
Why not now. An unread key accepted now would be silently ignored (#1773).
-
-
L7. Route re-authorization is plan I3c2’s (maintainer ruling, 2026-10-09; #2799). Every route a delegation caller reaches whose bar refuses a user gets an
Admissionwith a user arm, under two rules:-
Visibility is preserved. A user arm admits the roles canopy-web shows that surface to. A reader bar is
CASEWORKER_OR_ABOVE_ROLESplusanalystandstudio_adminwherever canopy-web shows them the surface. -
In-request service routes admit users via. A route that services reach inside a worker’s request admits users only through the arm listing those services, plus canopy-web or canopy-cli where they call it.
I3c2 holds the per-route inventory, including canopy-security’s admin-only reads that canopy-web shows to auditors and case roles, and the deliberate service-only bars it must judge (hearing view, the signed determination record). The switch waits on I3c2.
-
Translating today’s bars (for I3c2 and I3g)
| Today | I3c |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exact |
|
canopy-web’s service arms (eligibility’s |
retired; canopy-web calls as the user, and the handler’s user arm governs (I3c2 confirms each) |
snap’s |
|
|
|
|
|
WIC’s |
|
|
|
Units
Every commit goes through the J1–J8 review. Each subject is at most 72 characters with its ` (#N). Every new `.rs starts with the SPDX line.
-
U1 (w2)
docs(adr): record canopy-identity’s receivers(#2792).-
ADR. ADR-049 Amendment 14 (L1–L7) before
== References, plus the Status line. -
Plan page. This page (
In progress), with anIdentity Plane Split (epic &130)nav group above the archive line. -
I3c2’s issue (#2799), filed under &133 and related to #2792. It carries L7’s rules and the round-2 inventory’s counts and pointers. Its acceptance: plan I3c2 inventories every route a delegation caller reaches whose bar refuses a user, and names each route’s
Admission.
-
-
U2 (w2)
feat(auth): refuse a system token with no edge to its receiver(#2793, L3).-
identity_token.rs.Rejection::SystemEdge, last in the system path. -
canopy-security.
subject_token_reasongainssubject_token_system_edge. -
Tests.
a_system_token_passes_only_along_a_system_edge: everyConfidentialClient×CanopyService. Fixtures that use a pair with no edge move onto a real edge. -
Docs.
shared-crates.adoc.
-
-
U3 (w3)
feat(auth): refresh a receiver’s keys on a timer(#2794, L5).-
key_cache.rs.REFRESH_AHEAD,REFRESHER_LIVE,refresher_tickwith its generation, the drop guard, each fetch’s recorded outcome,KeyCache::start_refresher, and the no-wait rule. The module docs gain them. -
HttpJwksKeySource::start_refresherdelegates to it. -
Tests (tokio time paused, the injected
IdentityClockadvanced with it). The existing cache tests stay as they are and pass.-
an_idle_receiver_refreshes_before_its_set_reaches_300_s; -
a_revoked_key_stops_verifying_within_300_s_while_the_jwks_answers; -
a_jwks_outage_is_served_without_waiting_until_720_s; -
a_set_past_720_s_fails_closed; -
an_unknown_kid_still_waits; -
a_source_kept_past_its_runtimes_shutdown_waits_as_before: the refresher started, the runtime dropped, and a 300 s+ lookup on a new runtime fetches and waits; -
an_aborted_refresher_clears_at_once; -
a_refresher_that_stops_ticking_stops_granting_within_60_s; -
start_refresher_is_idempotent_and_restarts_after_its_task_ends; -
start_refresher_without_a_runtime_sets_nothing.
-
-
Docs.
shared-crates.adoc.
-
-
U4 (w3)
feat(auth): add the canopy-identity principal and its guards(#2795, L1, L2).-
New module.
crates/canopy-auth/src/identity_receiver.rs, withprincipal.rs,admission.rsanddenial.rsunderidentity_receiver/. Re-exported at the crate root. -
xtask.
role_vocabulary_scanlearns, inFN_CHECKS,user_roles(0) anduser_roles_via(1), and inMETHOD_CHECKS,and_user_roles(0) andand_user_roles_via(1). Its fixture test covers each. -
Tests.
-
admission_refusals_follow_their_order: one case per refusal rule, and one per admitting arm, over U+/U−, a listed and an unlisted actor, a listed and an unlisted system client, canopy-web, and P+/P−. -
actor_and_attribution_map_users_and_clients. -
client_is_the_system_client_or_the_current_actor. -
ownership_binds_only_the_portal. -
principal_debug_never_prints_the_token.
-
-
Docs.
shared-crates.adoc.
-
-
U5 (w3)
feat(auth): add the canopy-identity receiver layer(#2796, L4).-
identity_receiver/layer.rs.IdentityReceiver::new(validator)(anyIdentityKeySource,MemoKeySourceincluded) andwith_applicant_verifier;identity_receiver_middlewareandparse_bearer; the refusal type;RECEIVER_KEY_BUDGET. -
Dev-dependency. canopy-auth adds
canopy-test-lib, as canopy-db and canopy-api do. -
Tests, through a probe router with
tower::ServiceExt::oneshot:-
each L4 row, in L4’s order;
-
a principal inserted for a user, a system caller and the portal;
-
the budget passing on a stalled key source;
-
jws_evil_cases!through the layer; -
no_token_reaches_an_emitted_log_line: each refusal and an admitted request undercanopy_test_lib::observability::emitted_log_while(Level::TRACE, …)on acurrent_threadruntime, asserting on the serialized output; -
a proptest for
parse_bearer: it never panics,Bearer <t>over the b64token alphabet round-trips in any scheme case, and any other scheme is refused.
-
-
Docs.
shared-crates.adoc.
-
-
U6 (w2)
feat(auth): build a receiver from its settings(#2797, L6).-
canopy-auth.
identity_url.rs(moved);ReceiverSettings::newandjwks_uri();IdentityReceiver::over_http(&ReceiverSettings, CanopyService, IdentityHttpClient), which builds anHttpJwksKeySourceand callsstart_refresher. -
canopy-security.
config.rsuses the moved function through the 1:1From, and re-exportsIDENTITY_PATH. ItsIssuerConfigtests, the proptestissuer_validation_accepts_only_the_ruleincluded, are unchanged and still pass. -
Tests.
each_identity_url_defect_is_named, and a proptest thatidentity_urlaccepts only the rule;receiver_settings_name_the_defective_setting;the_jwks_uri_sits_under_the_internal_url;over_http_starts_the_refresher. -
Docs.
shared-crates.adoc.
-
-
U7 (w2)
test(auth): prove the receiver on the devstack identity plane(#2798).-
New test file.
crates/canopy-test-lib/tests/identity_receiver_test.rs(skips when the devstack is down, likeidentity_broker_test.rs). It runs a probe router behindIdentityReceiver::over_httpforCanopyService::Persons, from the broker’sBrokerConfig: the issuer,security_url+/identity, anddevelopment = true.-
a_caseworker_delegation_reaches_the_probe_as_its_realm_subject: the subject isSeedPerson::realm_subject, and the roles are the cast’s. -
a_token_for_another_receiver_is_token_rejected. -
a_portal_system_token_reaches_the_probe_as_the_portal:system(ConfidentialClient::Portal, CanopyService::Persons, Some("portal:persons:read")). -
no_bearer_is_token_missing.
-
-
Close.
-
CHANGELOG.adocAdded: one entry per unit U2–U7, citing ADR-049 Amendment 14 Ln, plan I3c Un and the issue. -
Amendment 14’s as-built, with its plan xref repointed to
plans/archive/. -
Plan I3c becomes
Done (YYYY-MM-DD) — !Nand moves toplans/archive/. Its nav entry moves to Archive, and the emptied nav group goes. -
cargo xtask plan-lint --done <i3c> --allow-open 1448 --allow-open 2648 --allow-open 2799, plus one--allow-openper U-issue. -
After the merge, epic &133 is updated.
-
-
Outcomes
-
Done when U1–U7 merge and U7’s devstack proof passes.
-
I3c2 then re-authorizes the delegated routes (L7).
-
The switch (I3g) installs the layer and translates each handler’s bars by the table and I3c2’s inventory.
Scope
In: the principal, Admission, the system-edge check, the layer, the keys' refresher, the receiver settings value, the devstack proof, and filing I3c2.
Out:
-
I3c2 (#2799): the per-route inventory and every route’s admission.
-
I3g: wiring canopy-api’s router,
AppState, idempotency,ServiceSettingsand/readyz; deletingAuthLayer,ReceiverContract, theClaimsbars,exchanged_gate, the hop-2 pair and the three rollout settings;qc_write_gate_sweep_test's adoption. -
I3d: senders, other clients' purposes, client keys, #2648.
-
Not now: program enforcement, and canopy-exchange as a receiver.
Risks
-
L5’s no-wait rule depends on positive evidence: a live refresher and a failed latest fetch. A dead refresher reverts within 60 s, and a cleared one at once. U3 pins the idle, shutdown, abort and outage cases.
-
Admission's via arm is only as narrow as I3c2 writes it. L7 states the rule, and I3c2’s review checks each row. -
L6 touches canopy-security’s boot config. The 1:1
Fromand the re-export keep it unchanged. -
Unwired code can drift from its consumers. The translation table and I3c2 are the contract. U7 proves the layer against the real issuer.
Verification
-
Per unit: fmt; clippy with validate’s flags; nextest for the touched crates (canopy-auth always; canopy-security for U2, U3 and U6; xtask for U4; canopy-test-lib for U7 with
CANOPY_TEST_INFRA=required); quality-budgets, plan-lint and check-docs. -
Per MR: the pre-push battery.
Review log
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic |
Claude Opus 5.5 (fresh subagent) |
no-ship. Five blockers, fixed in-plan:
Notes folded in. |
2 |
not stated (the maintainer’s other vendor) |
not stated |
5 findings (1 P1, 4 P2), fixed in-plan:
|