One trusted issuer with a declarative claim contract, introspection, and the OIDC-only ADR (epic &118)
Status: Done (2026-09-26) — !1518
Issues: #515, #514, #512 (epic &118)
Branches: feat/118-identity-claim-contract (carries this page)
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U-A starts. It ships as one MR with one battery, because the claim contract is read by canopy-auth, canopy-web and every service’s bootstrap.
Erratum (2026-09-26): xtask identity.rs gains its jurisdiction argument in U-B, which introduces IdentityConfig::load; U-A projects through ClaimContract::keycloak(). U-A’s mock issuer serves discovery and JWKS; U-C adds its token, exchange, refresh and introspection endpoints. Roles and programs sit in an opaque Claims.contract (ContractClaims), because the workspace denies mixing private and public fields; roles() and programs() read them.
Erratum (2026-09-26): D4’s JWKS unknown-kid recovery runs for every JWS-routed token (every token in jws mode, a JWS in auto mode), since the route, not the mode, decides which validator judges a token. An opaque exchange output is also held to the JWS output’s 300 s lifetime cap and no-refresh-token rule.
Context
Every worker write is an RFC 8693 exchange at one realm. Every service validates one issuer (crates/canopy-api/src/bootstrap.rs ~258-297).
-
The contract is hard-coded to Keycloak.
-
Claims.realm_access.roles(crates/canopy-auth/src/claims.rs~124, ~232) driveshas_role, everyrequire_*bar,is_service,service_id,policy::is_citizen_classandEffectiveUser::actor. -
Seven production readers read it directly: canopy-web
session.rs~318 andservices/canopy-web/src/auth/mod.rs~438, reportingaudit.rs~187, and enrollmentservices/canopy-enrollment/src/api/mod.rs195/231,successors.rs~107 andcontinuations.rs~125. -
primary_programsis a fixed top-level array (claims.rs ~180). Signing is RS256-only (jwks.rs~595).
-
-
implies trust that does not exist. Each entry carries its ownissuer_urlandaudience(crates/canopy-composition/src/idp.rs~62-93), and canopy-web validates each (services/canopy-web/src/auth/idp_runtime.rs~199-204). But the exchanger validates subjects against the boot realm only (services/canopy-web/src/main.rs~378; the eligibility hop-2 at ~264). Nothing checks that they agree.ProviderTypeis inert. -
No introspection.
validate_token/validate_current(jwks.rs ~546, ~570) are JWS-only.OidcDiscoverydropsintrospection_endpoint(discovery.rs~70-87). -
Docs overclaim. ADR-019 and ADR-023 list Authentik, Dex, Zitadel and Kanidm as working. As built, only Keycloak is supported. #512 was filed as a SAML-termination spike.
Rulings in force:
-
This must work in every jurisdiction without code changes: a jurisdiction’s broker product is configuration.
-
Pre-1.0 has no compatibility shims.
-
ADR-043:
EffectiveUser; the A3 contract is 401 invalid, 403 unauthorized. -
ADR-044: the role/program override lives in the IdP mapper.
-
ADR-046: the per-row issuer is deferred.
-
#1008:
OidcSubject, typed actors.
Scope
In scope: D1–D8.
Out of scope (GitLab follow-ups, linked from the closing comment):
-
trusting more than one issuer (ADR-048’s reopen trigger, which also re-arms #2335);
-
private_key_jwtclient authentication; -
validating the
id_tokenand a nonce; -
a per-issuer refresh lead;
-
#568 / #570 (epic &119, which builds on D2’s schema).
Design
Decisions
Invariants
-
Every bearer access token canopy accepts is from the one trusted issuer, validated under that issuer’s declared contract. The #1442 applicant ownership claim, canopy-signed, is separate.
-
A role canopy acts on from a validated token is in
ROLE_VOCABULARYand came from the contract’s sources. -
An identity outage is never an admission: no uncached token passes, and login never serves from cache.
-
No sender-constrained token is accepted as a bearer.
Units — U-A → U-D, one MR
Commit 1 is docs(plans): plan the identity claim contract and introspection (&118). The last is docs(plans): close the identity claim contract plan (&118).
U-A (w8) — feat(auth): project a declarative claim contract (#515)
Files:
-
crates/canopy-auth/src/{claims,jwks,effective_user,policy,receiver,token_exchanger,service_token}.rs, a newclaim_contract.rs; -
the seven direct readers;
-
every
Claims/RealmAccessliteral site; -
xtask
identity.rs, via a publicClaimContract::project(payload); -
canopy-test-lib’s mock issuer (D8).
Tests:
-
A proptest that pointer parsing and projection round-trip and never panic on arbitrary JSON.
-
The
keycloakdefault reproduces today’s roles on every existing fixture. -
Each D3 case: strict standard claims,
azp/client_idnormalization and conflict, the programs tri-state, an ignored unrelated malformed field. -
Service-prefix validation, with the service guards under it.
-
The algorithm allow-list refusing
none/HS*, and every key/algorithm mismatch. -
A
cnfor non-Bearertyprefused.
U-B (w8) — feat(web,composition): one issuer and an [identity] table (#515)
Files:
-
crates/canopy-composition/src/idp.rsand everyrulesets/*/idp.toml; -
canopy-auth
identity_config.rs(new); -
crates/canopy-api/src/bootstrap.rsandservices/canopy-portal/src/tokens.rs(loading[identity]); -
canopy-web
auth/{mod,idp_runtime,refresh}.rs,config.rs,session.rs(the verifiedsub/exp/jtistored beside the token),main.rs, the chip templates; -
docker-compose.ymlandconfig/canopy-web/(the deletedCANOPY_WEB__OIDC_keys); -
Studio
wizard.rs,validation.rs,bundle.rsand their templates; -
discovery.rsandjwks.rs(grant types, issuer binding); -
xtask
identity.rs(a jurisdiction argument that loads[identity]).
Tests:
-
Refused at boot: an issuer that does not advertise the exchange grant, and a discovery document whose
issuerdiffers from the configured one. -
canopy-web’s compose environment loads through
WebConfig. -
authorize_paramsreach the authorize URL, URL-encoded. A reserved name is refused at parse. -
Named login errors:
invalid_tokenandidentity_contracthere;identity_unavailablein U-C. -
The bundle round-trips through
IdpDocument::parse. -
keycloakfills its pointers, andoidc-genericrequires them.
U-C (w8) — feat(auth): RFC 7662 introspection and the validator dispatch (#514)
Files:
-
canopy-auth
validator.rs(new),introspection.rs(new),jwks.rs,middleware.rs(SubjectBearercarrying verified claims),token_exchanger.rs,service_token.rs,discovery.rs; -
crates/canopy-api/src/bootstrap.rs,services/canopy-eligibility/src/main.rs(the hop-2 exchanger),services/canopy-portal/src/tokens.rs; -
canopy-web wiring;
-
canopy-test-lib’s mock issuer (token, exchange, refresh and introspection endpoints, with fault injection and delay).
Tests:
-
Against the mock issuer:
-
an active or inactive token, projection, and a DPoP /
cnfresponse refused; -
freshness vs retention, eviction on
active: false, max entries; -
an outage is 503 with
serve_on_outageoff; with it on, only a retained verdict withinexpserves, never at login; -
Autonever falls back after a JWS failure.
-
-
ServiceTokenSourceunderRejectedandUnavailable. -
The exchanger never re-validates the subject and uses the bound claims. An opaque output is checked at the response level. The pinned 4 s budget is unchanged.
-
The
identity_unavailablelogin error.
U-D (w3) — docs: ratify OIDC-only identity in ADR-048 (#512)
Files:
-
docs/modules/ROOT/pages/adrs/adr-048-oidc-only-identity.adocand the ADR index; -
ADR-019 / ADR-023 corrections, the ADR-043 A3 amendment and the ADR-046 trigger;
-
shared-crates.adoc(Claims,roles(),IdentityConfig); -
idp-integration.adoc; -
worker-portal-redesign.adoc(its stale "SAML Done" line); -
CHANGELOG,
security.adoc/security-operations.adocfor the outage andserve_on_outagedoctrine; -
the api and data-model pages.
Verification
-
Per unit: fmt, clippy, non-live nextest and quality-budgets in isolated worktrees, with no live-devstack tests.
-
CANOPY_CARGO_FEATURES=canopy-api/test-clock cargo xtask dev reload, thengit push. The battery is the gate: the devstack realm keeps thekeycloakpreset, so every live and e2e test must pass unchanged.
Documentation Updates
-
ADR-048; the ADR-019 / ADR-023 / ADR-046 corrections;
idp-integration.adoc(the contract, presets,authorize_params, validation modes, the broker checklist). -
configuration-reference.adoc(the[identity]table),authorization-inventory.adoc(the 503 row), CHANGELOG (Changed: the idp.toml schema,Claims.roles(); Added: introspection, presets, algorithms; Removed:realm_access,default_role, per-entryissuer_url). -
GitLab: file the out-of-scope follow-ups; retitle #512 to the ratification framing.