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) drives has_role, every require_* bar, is_service, service_id, policy::is_citizen_class and EffectiveUser::actor.

    • Seven production readers read it directly: canopy-web session.rs ~318 and services/canopy-web/src/auth/mod.rs ~438, reporting audit.rs ~187, and enrollment services/canopy-enrollment/src/api/mod.rs 195/231, successors.rs ~107 and continuations.rs ~125.

    • primary_programs is 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 own issuer_url and audience (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. ProviderType is inert.

  • No introspection. validate_token / validate_current (jwks.rs ~546, ~570) are JWS-only. OidcDiscovery drops introspection_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_jwt client authentication;

  • validating the id_token and a nonce;

  • a per-issuer refresh lead;

  • #568 / #570 (epic &119, which builds on D2’s schema).

Design

Decisions

# Decision

D1

One trusted issuer.

  • canopy trusts exactly one issuer, canopy-identity: sign-in, refresh, both exchangers, every service and service-token self-validation.

  • Upstream IdPs of any protocol (SAML, LDAP/AD, other OIDC) federate into it.

  • An entry is a sign-in chooser entry that selects an upstream through authorization parameters. It never names its own issuer.

  • canopy-web’s sign-in uses the same oidc_issuer / oidc_internal_url pair (crates/canopy-common/src/settings.rs ~45-52) as its exchanger.

    • The WebConfig devstack overrides (oidc_client_id, oidc_external_issuer, oidc_internal_issuer, services/canopy-web/src/config.rs ~48-70) and apply_devstack_issuer_override (auth/idp_runtime.rs) are deleted.

    • So are their CANOPY_WEB__OIDC_* keys in docker-compose.yml (~1648-1670) and every config/canopy-web file.

    • A test loads canopy-web’s compose environment through WebConfig (deny_unknown_fields), so a stale key fails the build.

  • Discovery is bound to the issuer. The configured oidc_issuer is canonical. A discovery document, fetched from oidc_internal_url or the issuer, whose issuer differs is refused at boot. Today the provider adopts discovery.issuer (jwks.rs ~218). A test covers a mismatched response.

  • canopy-web and every service refuse to boot when discovery does not advertise the RFC 8693 grant (urn:ietf:params:oauth:grant-type:token-exchange in grant_types_supported). Devstack Keycloak 26.5 advertises it (checked 2026-09-26). The check is necessary, not sufficient (D6).

  • Trusting a second issuer is ADR-048’s reopen trigger.

D2

idp.toml: one [identity], N (crates/canopy-composition/src/idp.rs, deny_unknown_fields).

  • [identity] carries:

    • client_id (the sign-in client) and audience (what canopy-web requires on sign-in tokens);

    • scopes (default openid profile email);

    • provider (D6);

    • the claim contract (D3);

    • validation (D4) and its introspection knobs.

  • :

    • keeps slug, label, chip_color, chip_icon and domain_match (email discovery is unchanged);

    • gains authorize_params, a string map of extra authorize parameters such as kc_idp_hint;

    • loses provider_type, issuer_url, internal_issuer_url, client_id and audience.

  • authorize_params may not name an application-controlled parameter: response_type, client_id, redirect_uri, scope, state, nonce, code_challenge, code_challenge_method, response_mode, request or request_uri. These are refused at parse. The URL is built with url::Url::query_pairs_mut, never by concatenation. An entry with no params renders the broker’s own chooser.

  • The document loses default_role: it has no reader, and its doc promises a fallback that #1024 forbids. roles (the composition catalog) and local_accounts are unchanged.

  • The issuer URL stays deployment configuration (D1). It differs per deployment and per devstack port.

  • Ownership. canopy-auth owns IdentityConfig: serde, validation, presets, and a tolerant IdentityConfig::load(rulesets_dir, jurisdiction) that projects only [identity] from idp.toml (the LoggingPolicy::load pattern, crates/canopy-common/src/telemetry/policy.rs ~383-403). canopy-composition embeds it in IdpDocument and gains a canopy-auth dependency (no cycle).

  • Readers: crates/canopy-api/src/bootstrap.rs, services/canopy-portal/src/tokens.rs, the eligibility hop-2 exchanger, and canopy-web (through IdpDocument).

  • Receiver audiences are unchanged: canopy, canopy-internal-service, and the service’s own audience where accept_own_audience is set (bootstrap.rs ~288).

  • Studio’s wizard and bundle.rs write the new schema. A round-trip IdpDocument::parse test replaces the toml::Value-only check.

D3

Claims from the verified payload (canopy-auth).

  • Raw, then normalized. validate_current verifies the signature once and decodes the payload into a raw JSON map (a PARTNER-EDGE-UNTYPED marker: the IdP token is a partner edge). Claims is then built from that map:

    • standard claims (sub, aud, exp, jti, scope, typ) are parsed strictly, and a wrong type is a ContractViolation;

    • azp comes from azp, else client_id (RFC 9068). Both present and different is a ContractViolation. The introspection path normalizes identically;

    • contract fields are projected through the pointers;

    • other top-level fields are ignored, so an unrelated malformed field never blocks a token.

  • ClaimContract:

    • roles: one or more {pointer, shape} sources (RFC 6901; array or object_keys), unioned;

    • programs: {pointer, shape}. It projects to a tri-state ProgramsClaim (Missing | Malformed | Valid(list)), which canopy-web’s program scope maps onto ADR-044’s missing / malformed codes. A scalar is never a decode 401;

    • service_prefix (default service:): non-empty, and not a prefix of any ROLE_VOCABULARY entry, both checked at parse;

    • algorithms: an allow-list from RS256/384/512, PS256, ES256/384 and EdDSA (default [RS256]). none and HS* are refused at parse.

  • Key and algorithm binding (RFC 8725). The header alg must be allowed, must equal the JWK’s alg when present, and must fit its key type: RSA for RS/PS, P-256 for ES256, P-384 for ES384, Ed25519 for EdDSA. Validation runs with exactly that algorithm, and a mismatch is Rejected.

  • realm_access and RealmAccess are deleted. Claims::roles() is the private, sorted, normalized set. Every reader switches to it, including the seven direct readers and xtask identity.rs.

  • Projection keeps only service_prefix values and canopy_auth::ROLE_VOCABULARY roles. The vocabulary is the union of every bar constant, inline role slice and WorkerRole source name (canopy-web’s analyst included), pinned by a test. IdP groups and Keycloak defaults never reach audit payloads (ADR-044: operators map in the broker).

  • Synthetic claims use Claims::new(sub).with_roles(..), documented as synthetic-only. Every Claims { .. } / RealmAccess { .. } literal (about 65 / 39, benches included) moves to it.

  • An absent roles source yields no roles (403, or no-role admission). A wrong-typed one is a ContractViolation: 401 at receivers, a named login error at canopy-web.

  • Claims::parsed_primary_programs (no caller) and its pre-ADR-044 docs are deleted.

D4

Validation strategies (#514).

  • TokenValidator (canopy-auth) is Jws | Introspect | Auto, selected by [identity].validation (default jws). It is held by AuthLayer, canopy-web’s issuer runtime and ServiceTokenSource.

  • Auto dispatches on format: a compact JWS with a kid goes to JWS, anything else to introspection. It never introspects after a JWS failure.

  • Sender constraints are refused. A JWS carrying cnf, or typ other than absent or Bearer, is Rejected. So is an introspection response whose token_type is not absent or Bearer (e.g. DPoP), or that carries cnf. canopy verifies no proof of possession (RFC 9449).

  • Introspection (RFC 7662):

    • client_secret_basic with the caller’s own oidc_service_client_* credentials. introspect / auto refuse to boot without them; canopy-rules, canopy-persons, canopy-exchange and canopy-security hold none today, so the deployment provisions them;

    • each receiver introspects only tokens addressed to it;

    • the endpoint comes from discovery (introspection_endpoint, now parsed) or [identity].introspection.endpoint;

    • active: false is Rejected, and exp is required;

    • connect 500 ms, total 1 s.

  • Cache (moka, keyed by SHA-256 of the token):

    • a freshness deadline, cache_ttl_secs: a hit within it serves without a call, which also hides an outage;

    • a retention deadline, the token’s exp: a stale entry is kept only for serve_on_outage;

    • active: false evicts at once, there is no negative caching, and size is bounded by cache_max_entries.

  • Outage. A fresh-miss that hits Unavailable returns 503 identity_unavailable, a new frozen-contract row. With serve_on_outage (default false) it serves a retained positive verdict within exp instead. Never an uncached token, and never at canopy-web’s login callback.

  • ServiceTokenSource. Its self-revalidation age is capped at the freshness deadline. Rejected drops and re-mints the token; Unavailable follows serve_on_outage. The JWKS unknown-kid recovery runs only in jws mode (service_token.rs ~451-600).

  • The exchange path makes no introspection call.

    • SubjectBearer carries the sub, exp and jti verified when that exact token was validated: canopy-web at login and refresh, stored in the session beside the token; receivers at AuthLayer ingress. The exchanger checks those and never re-validates the subject.

    • In jws mode the output is validated locally, as today. In introspect / auto mode an opaque output, received from the authenticated token endpoint, is checked at the response level (issued_token_type, scope ⊆ requested, expires_in). Its receiver, which is in its audience, validates it.

    • WORST_CASE_EXCHANGE (3.75 s) and canopy-web’s 4 s leg (actions.rs ~787-810, pinned at ~1634) are unchanged in every mode.

D5

canopy-web sign-in.

  • One issuer runtime replaces the per-entry validators. The authorize URL carries [identity].scopes and the chosen entry’s authorize_params (D2).

  • A validation failure at the callback or refresh gets a named login error with telemetry, never a bare /login loop: invalid_token, identity_contract, identity_unavailable (services/canopy-web/src/auth/mod.rs ~143-151).

  • WorkerRole admission reads Claims::roles() (from_keycloak_roles becomes from_roles), and program scope reads the ProgramsClaim.

D6

provider is a required preset: keycloak | oidc-generic.

  • keycloak supplies /realm_access/roles (array) and the primary_programs claim. It reproduces today’s authorization decisions; only non-vocabulary roles leave the audit payloads.

  • oidc-generic supplies no pointers, so the contract is explicit. Any broker that meets the claim contract and canopy’s exchange topology works without code changes.

  • The exchange topology: hop 1 exchanges a worker token for a two-audience service token, and hop 2 narrows to a downstream audience absent from its input (idp-integration.adoc).

  • Vendor presets are added only once a vendor is verified end to end. Per their current documentation, Authentik issues one exchange audience and ZITADEL limits output audiences to the input’s. ADR-048 records both as incompatible with that topology, so #515’s "widen ProviderType" is answered by oidc-generic plus those findings.

  • Studio’s list (studio/validation.rs ~26), the chip set and the template select move with the enum. saml stays rejected (idp.rs unknown_provider_type_rejects).

D7

ADR-048: OIDC-only (#512 closes on it).

  • canopy is an OIDC relying party and an OAuth 2.0 resource server only, with no SAML SP.

  • Worker writes need RFC 8693 and service identity needs client_credentials, both OAuth-only. SAML, LDAP and AD sources federate into the one issuer (D1).

  • It states:

    • the broker’s obligations canopy cannot check: role and program mapping, MFA, sub stability across re-links, deprovisioning within one access-token lifetime;

    • the exchange topology, the verified broker (Keycloak 26.2+), and the recorded incompatibilities.

  • Reopen triggers:

    • a policy authority forbids a broker for worker authentication;

    • a mandated identity source no RFC 8693 issuer can broker;

    • cross-jurisdiction federation.

  • It corrects ADR-019 / ADR-023’s provider overclaims, retiring ADR-019’s dead CANOPY_IDENTITY_ROLES_CLAIM_PATH / SERVICE_ROLE_PREFIX rows.

  • It amends ADR-043 A3 with the 503 row.

  • It restates ADR-046’s per-row-issuer trigger as "more than one trusted issuer" (#2335 updated).

D8

Offline test matrix.

  • canopy-test-lib gains a claim-template mock issuer (hand-rolled axum), used from integration tests (crates/canopy-test-lib/tests/, canopy-web and service tests); canopy-auth’s unit tests keep in-crate fixtures. It serves:

    • discovery (introspection endpoint, grant types, a settable issuer);

    • JWKS (RS256, PS256, ES256 keys, with and without alg);

    • token, exchange and refresh endpoints;

    • introspection with fault injection and delay.

  • Rows: the keycloak template and an oidc-generic template with custom pointers. Each is asserted at rederive_authz, the ReceiverContract bars, EffectiveUser::actor, the exchanger and ServiceTokenSource. The columns:

    • roles present / absent / empty / wrong-typed;

    • programs array / scalar / absent;

    • azp / client_id / both-differing;

    • aud shapes;

    • cnf / DPoP;

    • key-algorithm mismatches;

    • a cold-cache delayed introspection;

    • a discovery issuer mismatch.

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_VOCABULARY and 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 new claim_contract.rs;

  • the seven direct readers;

  • every Claims / RealmAccess literal site;

  • xtask identity.rs, via a public ClaimContract::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 keycloak default reproduces today’s roles on every existing fixture.

  • Each D3 case: strict standard claims, azp / client_id normalization 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 cnf or non-Bearer typ refused.

U-B (w8) — feat(web,composition): one issuer and an [identity] table (#515)

Files:

  • crates/canopy-composition/src/idp.rs and every rulesets/*/idp.toml;

  • canopy-auth identity_config.rs (new);

  • crates/canopy-api/src/bootstrap.rs and services/canopy-portal/src/tokens.rs (loading [identity]);

  • canopy-web auth/{mod,idp_runtime,refresh}.rs, config.rs, session.rs (the verified sub / exp / jti stored beside the token), main.rs, the chip templates;

  • docker-compose.yml and config/canopy-web/ (the deleted CANOPY_WEB__OIDC_ keys);

  • Studio wizard.rs, validation.rs, bundle.rs and their templates;

  • discovery.rs and jwks.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 issuer differs from the configured one.

  • canopy-web’s compose environment loads through WebConfig.

  • authorize_params reach the authorize URL, URL-encoded. A reserved name is refused at parse.

  • Named login errors: invalid_token and identity_contract here; identity_unavailable in U-C.

  • The bundle round-trips through IdpDocument::parse.

  • keycloak fills its pointers, and oidc-generic requires 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 (SubjectBearer carrying 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 / cnf response refused;

    • freshness vs retention, eviction on active: false, max entries;

    • an outage is 503 with serve_on_outage off; with it on, only a retained verdict within exp serves, never at login;

    • Auto never falls back after a JWS failure.

  • ServiceTokenSource under Rejected and Unavailable.

  • 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_unavailable login error.

U-D (w3) — docs: ratify OIDC-only identity in ADR-048 (#512)

Files:

  • docs/modules/ROOT/pages/adrs/adr-048-oidc-only-identity.adoc and 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.adoc for the outage and serve_on_outage doctrine;

  • the api and data-model pages.

Verification

  1. Per unit: fmt, clippy, non-live nextest and quality-budgets in isolated worktrees, with no live-devstack tests.

  2. CANOPY_CARGO_FEATURES=canopy-api/test-clock cargo xtask dev reload, then git push. The battery is the gate: the devstack realm keeps the keycloak preset, 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-entry issuer_url).

  • GitLab: file the out-of-scope follow-ups; retitle #512 to the ratification framing.

Review log

round vendor resolved model verdict

1 (2026-09-26)

Anthropic

claude-opus-5-5

no-ship — eight blockers fixed:

* commit subjects over 72 characters; * D1’s pack-issuer check against D2’s deletion (one issuer key; the WebConfig overrides go; the exchange-grant check verified live); * the pinned 4 s exchange leg (per-mode budgets; introspect trusts the issuer’s subject validation); * exhaustive field lists; * ROLE_VOCABULARY as the filter’s single source; * Claims::with_roles for synthetic claims; * IdentityConfig's owner and readers (canopy-portal, the hop-2 exchanger, bootstrap); * introspection credentials required, with boot refusal.

2 (2026-09-26)

OpenAI

gpt-6-astra

no-ship — 15 findings fixed in revision 3:

* the exchange path makes no introspection call (bound subject claims; response-level output checks; the budget unchanged); * presets reduced to keycloak / oidc-generic, with the Authentik / ZITADEL exchange incompatibilities recorded; * sender constraints (cnf, DPoP) refused; * the canopy-internal-service audience kept; * compose CANOPY_WEB__OIDC_* keys deleted, with a load test; * client_id normalized on both paths; * raw-then-normalized claims with a programs tri-state; * service-prefix validation; * discovery bound to the configured issuer; * the auto budget; * separate freshness and retention deadlines; * ServiceTokenSource bounded by freshness; * key/algorithm binding; * reserved authorize_params.

No round 3.

Edit this page · default