ADR-043: OIDC Program Amendments — Citizen-Path Credential, Exchange Semantics, and the Frozen Rejection Contract
Status: Accepted (2026-08-17); amended by ADR-049 (2026-09-30), effective 2026-10-12: Amendment 3
Issue: #1419 (OIDC F1b; program activated by the 2026-08-10 maintainer ruling on #546, note 3666918785)
Amends: ADR-023 (immutable — its amendments ride here per the ruling)
Relates to: ADR-019 (service identity), ADR-026 (opaque portal sessions), ADR-014 (audit chain), epic &52, the F1a inventory
Context
ADR-023 mandated OIDC validation at every program service, RFC 8693 token
exchange for user-context requests, citizen-upload isolation, and service-class
credential narrowing. The 2026-08-10 ruling activated the full program and
resolved the five architect flags; ADR-023 itself is immutable, so the
resolutions that CHANGE its text are recorded here, on the program’s first
implementing MR, alongside the one piece of shared machinery every later slice
consumes (the EffectiveUser resolution, below).
Amendments to ADR-023
A1 — The citizen-path credential is a dedicated narrow IdP service account (ruling R2)
ADR-023 Decision 3 derived the citizen-upload credential "via RFC 8693 token
exchange at the moment the citizen-content boundary is crossed". That mechanism
is replaced: RFC 8693 requires a subject token, and under ADR-026 the
applicant portal holds an opaque Redis session — no citizen token exists to
exchange. Citizen-content processing instead authenticates with a
dedicated narrow IdP service account (client_credentials), provisioned
with exactly Decision 3’s four scoping dimensions (narrowed aud, operation
scopes, short exp, optional cnf). Only the derivation mechanism changes;
the scoping posture is unchanged.
Landed (#1440, OIDC P1): the narrow account is real — the portal holds one
scope-aware client_credentials source per backend target (each minting with
the aud-canopy-<target> optional client scope and self-validating against
its own target audience), the realm client carries no broad
canopy-internal-service mapper (a scope-less mint yields a token no
receiver accepts), and access.token.lifespan = 600 covers the short-exp
dimension (cnf remains optional/deferred).
Landed (#1442, OIDC P3 — ownership binding; design adjudicated
2026-08-23): the narrow credential’s REACH inside its classified surface
is bound to the citizen’s own resources. The portal signs a 120-second
ES256 ownership claim per resource-keyed call (X-Canopy-Applicant;
canopy_signing::applicant_claim — the ADR-019 actor-token idiom in a
DISTINCT aud namespace and on a DISTINCT header, because actor presence
drives audit attribution and gates like enrollment’s #408): sub = the
ADR-026 session’s application id, plus the household/person bindings the
portal resolved through its own authenticated applications read. The
claim key is a separate secret from the OAuth2 client secret — that
separation IS the threat model: an attacker holding only the stolen
narrow bearer cannot mint claims, and every resource-keyed route fails
closed (403 ownership_claim_missing; a foreign binding is 403
ownership_mismatch on claim-local compares and a UNIFORM 404 on
post-load compares, so denial never confirms a foreign resource exists).
Verification: kid-registered public key at each origin (the web-actor
#1009 distribution shape — env override or .keys/), one shared
fail-loud boot helper. The intake surfaces (create-draft,
verify-credential, recovery) are exempt: they ARE the authentication
that creates the binding. Ownership of resources ACROSS services stays
attested by the portal from its authenticated reads — the same trust
root as the session itself.
Landed (#1441, OIDC P2): the operation-scope dimension is enforced
receiver-side. The portal credential is a compiled CITIZEN CLASS
(canopy_auth::policy::CITIZEN_CLASS_SERVICE_IDS — compiled rather than
config so an empty allowlist cannot fail open; role half and azp half
recognized independently): Claims::require_service_caller refuses it (403
portal_on_non_portal_route) and every service-accepting receiver arm
delegates there, so the narrowed token reaches NOTHING in its 8 targets
except routes explicitly classified portal-reachable, which re-admit it on
azp allowlist + a per-route-family operation scope (the 12-scope
portal:* vocabulary; 403 portal_scope_missing without it, 403
portal_only_route for non-citizen principals on the portal-only intake
surfaces). This amends ADR-019’s "Per-service token audience …
Single aud: canopy-internal-service is sufficient" non-goal FOR THE PORTAL
ONLY — the rest of the fleet’s service tokens stay broad until the deferred
FU-A (#1447).
Consequently the citizen_upload exchange-purpose code in ADR-023 Decision 6
is retired unused: no exchange occurs on the citizen path (nor on background
paths — background_job is likewise unused). In v1 the auth.token_exchange
audit stream (A1, #1424) carries the plan’s frozen purpose vocabulary:
worker_request | orchestrator_fanout (the web edge and the eligibility
hop-2 fan-out).
A2 — GA exchange semantics: sub preserved, azp names the exchanger, act unused
Keycloak’s generally-available token exchange emits the exchanged token with
the subject’s sub preserved (the worker remains the subject) and the
exchanging client visible as azp. The act (actor) claim is an
experimental Keycloak surface and is not used — no canopy receiver may
depend on act. Receivers authorize the user-context arm on exactly: target
audience match + azp in the authorized-exchanger allowlist + required worker
role in realm_access.roles (the plan’s receiver contract).
Hop-2 pair refinement (#1430). "Target audience match" means the token’s
aud is exactly [target] — with ONE structured exception: a hop-2
receiver (a service whose own paired exchanger re-exchanges inbound
user-context bearers for a fan-out; canopy-eligibility today) also accepts an
aud of exactly the {target, target’s-paired-exchanger} pair, because
Keycloak V2 requires the subject of a chained exchange to name the requesting
exchanger in aud. The pair is opted into on BOTH ends — the sender’s
ExchangeRequest.hop2_exchanger (the broker refuses a grant missing either
entry or carrying an unrequested exchanger rider) and the receiver’s
ReceiverContract::with_hop2_exchanger (every other service, and every other
multi-audience shape, stays exactly-single). A pair token replayed at a
single-exact service is 403 aud_not_exact there.
A3 — The frozen 401/403 contract
Fleet-wide, non-negotiable, encoded in middleware, receivers, and the S6 conformance matrix:
-
401 — no token, structurally invalid token, or a token that fails cryptographic/issuer/typ validation — including ANY request carrying the retired
X-Canopy-Actorheader (C1, #1443: a stale sender fails loud). -
403 — a validated token that is unauthorized for the route: wrong
aud,azpnot allowlisted, missing role, or a service-class bearer on a user-only route.
A4 — Decision 3 narrowed to credential + data isolation
ADR-023 Decision 3’s isolation claim is narrowed to credential and data isolation: the narrow service account bounds what a compromised parse can reach. Process/RCE isolation (parsing in a separate process/container with its own kernel attack surface) is explicitly out of v1 scope and named as future defense-in-depth — FU-C, #1449.
A5 — Revocation guidance corrected (FU-D)
ADR-023 Decision 5’s cargo xtask identity revoke <jti> misstates RFC 7009:
the revocation endpoint revokes token values (the token string presented),
not JTIs. Operational guidance and any tooling must take the token value;
the operational replacement is Security Operations › a compromised exchange chain (#1450).
Decision (F1b machinery): EffectiveUser
The F1a inventory catalogued four
incompatible readings of "no actor" across its 467 read-verified branches. An exchanged worker
bearer has claims.actor() == None with the identity in the token itself —
all four readings misclassify it. Before any receiver flips:
canopy_auth::EffectiveUser is the single resolution of "who is the human
behind this request":
-
Direct(user)— the bearer is the human: any non-service token (worker, applicant, and every exchanged token — A2’ssub-preserved shape keeps the identity in the bearer). -
System(service)— a service bearer with no user context: genuine background/system traffic. -
ViaActor { bearer, actor }— RETIRED (C1, #1443, executing ruling R6): the transitional legacy-service-bearer + middleware-verifiedX-Canopy-Actorshape existed until every migrated surface flipped; post-C1 the middleware rejects the header outright and the resolution is total over the two shapes above.
It exposes both an authorization verdict (require_user → 403 per A3 —
the no-actor-rejects pattern) and a subject-to-attribute projection
(attribution_sub — the attribution-resolution pattern; System attributes
the calling service itself, exactly what the legacy
actor().map_or(claims.sub, |a| a.sub) shape did). is_system() serves the
passes-with-audit pattern. F1b changes no call sites — the S-slices adopt
per service, consulting the inventory.
Consequences
-
The F1a inventory’s blocking finding stood until the slices landed; the transition wired verifiers at applications/tanf and the middleware 401’d unverifiable headers. Post-C1 (#1443) the 401 is UNCONDITIONAL: the header is retired, the verifiers are gone, and worker identity rides exchanged bearers only.
-
Receivers gain one vocabulary for "who did this", so the S-slice diffs are mechanical substitutions with per-route classification from the inventory.
-
The unused
citizen_upload/background_jobpurpose codes die in the A1 audit schema rather than shipping as dead vocabulary.
Amendment 1 (2026-09-26, #1008) — the typed actor
Status unchanged (still Accepted). The §Decision’s attribution_sub
projection returns the bearer’s sub for both shapes, so a column that
records it cannot say whether a human or a service acted. Columns that
parsed it into a UUID also lost every non-UUID subject, and some recorded a
nil UUID for a service. This amendment types the actor. It refines the
§Decision; A1–A5 are unchanged.
-
The subject.
canopy_types::identity::OidcSubjectis the OIDCsub: 1–255 bytes of ASCII with no control character (OIDC Core 1.0 §2), compared byte for byte. It is never trimmed, case-folded or parsed as a UUID.canopy_auth::Claims.subis anOidcSubject, so a token whosesubbreaks the invariant fails validation (401, per A3).Claimshas noDefault: no subject is a valid default. -
The service.
ServicePrincipalnames a service: the name in a service bearer’sservice:<name>role (ADR-019), or the name a job gives its own service. It has the same invariant. Both types check shape, not provenance; onlyClaims.subandactor()carry a bearer’s. -
The actor.
ActorisHuman { subject: OidcSubject }orService { service: ServicePrincipal }, internally tagged onactor_typeon the wire. -
From the bearer.
EffectiveUser::actor() → Result<Actor, ApiError>mapsDirecttoHuman(the bearer’ssub, exchanged tokens included, per A2). It mapsSystemtoService, named by the bearer’sservice:role, never by theazpfallbackClaims::service_idalso reads (the #596 misattribution);azpis only checked against the role. The conversion is fallible, and aSystembearer is 403 (validated, but not attributable) when itsservice:roles name more than one distinct service, when it is citizen-class (is_citizen_class) and itsazpnames a different service than its role, so a portal act is never recorded as another service, or when the name breaks theServicePrincipalinvariant. -
Never from a body. An actor comes from the bearer (
actor()) or, for a write no request drives (a scheduler, saga or subscriber), from the job itself naming its own service. It is never read from a request body or path. A body or query field survives only as a referent: a worker the request names who is not the caller. -
Storage. Each attribution column takes one of three shapes. A human-only act is one
TEXTcolumn holding anOidcSubject. A service-reachable act is the pair<col>(subject) and<col>_service(principal), withCHECK (num_nonnulls(<col>, <col>_service) = 1)when the act is mandatory, and⇐ 1plus the act’s own predicate when it is optional.Actor::from_columnsrefuses both set andActor::columnsyields the pair to bind. A referent is aTEXTcolumn holding anOidcSubject. A nil UUID is not an actor. -
attribution_substays. It remains the string projection for uses that are not attribution columns: the idempotency principal,accessed_by, logs. A column recordsactor()instead.
Amendment 2 (2026-09-26, #514, ADR-048) — A3 gains a 503 row
Status unchanged (still Accepted). Under the one trusted issuer of
ADR-048, #514 adds RFC 7662
introspection: with [identity].validation = "introspect", or "auto" for
any token other than a compact JWS whose header decodes and names a kid
(TokenValidator::route, crates/canopy-auth/src/validator.rs), a receiver
asks the issuer to decide a token,
so a token can meet an issuer that cannot answer. A3 answered only "invalid"
(401) and "unauthorized" (403). Neither fits: the token was not judged, and
admitting it would make an outage an admission. A3 gains a third row:
-
503
identity_unavailable: the issuer could not be asked (a transport failure, a timeout, a non-2xx answer or a malformed body), and no fresh verdict for the token is held. The request is refused. An identity outage is never an admission: no uncached token passes.
As built, ApiError::identity_unavailable() (crates/canopy-common/src/error.rs)
renders the 503 with the stable code IDENTITY_UNAVAILABLE
("identity_unavailable"), and crates/canopy-auth/src/middleware.rs returns
it for ValidationFailure::Unavailable (crates/canopy-auth/src/validator.rs).
Only introspection can be unavailable; in jws mode every failure is still a
401. A verdict fetched within cache_ttl_secs is served without a call, so a
fresh verdict hides an outage. The one exception to the row is
[identity.introspection].serve_on_outage (default false): past freshness,
while the issuer cannot be asked, the receiver serves the retained positive
verdict for that exact token, and only until its exp plus the 60 s
validation leeway, the JWS path’s expiry rule
(crates/canopy-auth/src/introspection.rs). canopy-web’s sign-in and refresh
never read the cache: an outage there is the identity_unavailable login
error, not a 503 and never an admission.
The 401 and 403 rows are unchanged. A token whose sub breaks the
OidcSubject invariant is 401 (Amendment 1), and so is a token that breaks
the issuer’s declared claim contract (#515): both failed validation.
Amendment 3 (2026-10-12, #2883, ADR-049) — the amendments on canopy-identity
Status unchanged (still Accepted). ADR-049 makes canopy-identity the one issuer every receiver trusts, and its plan I3g made that effective. It supersedes A1’s mechanism, A2, A3’s codes, A5, the F1b machinery and parts of Amendments 1 and 2. A4 stands. In-document amendment, not an edit to A1–A5.
-
A1: the portal’s system tokens. The narrow IdP service account and its per-target
aud-canopy-<target>sources are gone.PortalSendermints a canopy-identity system token withprivate_key_jwtfor each of the portal’s nineSystemedges, refuses any other target locally, and carries that purpose’sportal:*scopes (ADR-049 D11; Amendment 3, A2; Amendment 23, O7). A receiver admits the portal only on a route’s portal arm holding its scope: otherwise 403portal_on_non_portal_routeorportal_scope_missing, and any other caller on a portal-only route 403portal_only_route. The P3 ownership claim (X-Canopy-Applicant) stays portal-signed with its own key and is verified for the portal’s token only (Amendment 14, L4); its 403s are unchanged. -
A2: per-hop delegation. Keycloak’s exchange is gone:
subpreserved,azpchecked against an exchanger allowlist, the unusedact, the hop-2 pair andaud_not_exact. A worker’s call carries a delegation token: one audience, the canopy subject assub, and an RFC 8693actchain whose current actor is the presenting client (D3, reversing A2’s unusedact). A receiver accepts it when that actor holds a delegation edge to it (Amendment 7, G8). The route’s admission then admits the worker’s roles from any actor (user_roles) or only through listed actors (user_roles_via). -
A3: the same split, with codes. A token failure is still 401 and a validated but unauthorized token still 403 (Amendment 14, L2 and L4):
-
401
token_missing(challengeBearer) ortoken_rejected(Bearer error="invalid_token"); -
403
required_role_missing,actor_not_allowed,system_caller_required,service_class_on_user_only,service_not_allowlistedand the portal codes above.
Two rows change. The retired
X-Canopy-Actorheader is a 400 (actor_header_retired, RFC 6750 §3.1), checked before any key lookup. A receiver whose key set did not answer within its budget answers 503keys_unavailable, which never admits. -
-
Amendment 2’s 503 row goes with introspection. Receivers verify canopy-identity’s JWS against its published keys and never ask the issuer to judge a token (D3), so
identity_unavailableandserve_on_outageare gone from receivers.identity_unavailableremains canopy-web’s sign-in refusal code. -
A4 stands. The portal’s system tokens bound what a compromised parse can reach; process isolation remains FU-C (#1449).
-
A5: revocation is canopy-security’s. No access token is revoked individually; each lives at most 300 s (delegation) or 600 s (system). canopy-security suspends subjects, revokes sessions, disables clients and revokes keys (D12), from canopy-web’s security-administration pages. canopy-identity’s RFC 7009 route takes a session’s own credential (canopy-web’s session, canopy-cli’s refresh credential), never an access token.
-
The F1b machinery:
Principal.EffectiveUserandClaimsare gone. The receiver inserts aPrincipal: a user, from a delegation token, or a system caller, from a system token (crates/canopy-auth/src/identity_receiver/principal.rs).principal.admit(&ADMISSION)?is the authorization verdict, andattribution_sub()andactor()keep their projections. -
Amendment 1: the typed actor stands; its sources change.
OidcSubject,ServicePrincipalandActorare unchanged.actor()names a user by the canopy subject’s hyphenated form, which the seed links keep equal to the realm ids rows already hold (ADR-049 K8), and a system caller by its client id, not aservice:role.attribution_sub()gives the canopy subject or the client id (Amendment 3, A4). The 403s for a bearer naming several services, or a portal bearer naming another, are gone: a system token names exactly one client.