IdP Integration
- The shape
- The issuer identifier and metadata
- The upstream profile
- What an upstream must deliver
- The supported upstreams
- Registering canopy’s clients
- canopy-web’s sign-in
- canopy-identity’s federation grant
- Device approval and native sessions
- Gating a deploy:
canopy-manage identity check - Keys and rotation
- Troubleshooting
- Implementation references
For an operator or identity-provider administrator standing up, checking or swapping the identity provider behind a canopy deployment.
canopy-identity, a module of canopy-security, is the one issuer every canopy service trusts (ADR-049). Workers sign in at one upstream OpenID Connect provider, Kanidm by default, or Keycloak or ZITADEL, the tested alternatives (ADR-050; The supported upstreams), and canopy-identity federates that sign-in into a canopy session. No service ever sees an upstream token: every call carries a canopy-identity token. The services once trusted Keycloak directly; ADR-049 records the move.
The shape
-
The upstream signs workers in at canopy-web, and nowhere else. canopy-web is its one relying party, a confidential client (
crates/canopy-auth/src/upstream/relying_party.rs). -
canopy-identity verifies the upstream’s id_token again under the deployment’s upstream profile, projects its claims to roles, programs and a username, links the upstream identity to a canopy subject, and opens a web session (canopy-identity’s federation grant). From that session it mints canopy-web a delegation token per target service (at most 300 s), and a service one onward from a delegation addressed to it. It mints each confidential client a system token for its compiled edges (600 s), the portal’s scoped
portal:*, and serves canopy-cli’s device flow (Device approval and native sessions). -
The receivers. Every service’s
/v1validates canopy-identity tokens against the issuer’s published keys and admits each route’s callers by name (Security › The identity receiver). -
Applicants have no identity-provider account. The applicant portal sends its own system tokens and its signed applicant claim (ADR-026).
| Setting | Home |
|---|---|
The issuer identifier and its internal URL |
|
The upstream profile |
|
The client registry |
|
Each client’s private key |
|
canopy-web’s upstream client secret and public origin |
|
canopy-cli’s device page |
|
A jurisdiction’s idp.toml holds only its [roles.*] composition role catalog (ADR-022). The upstream is deployment configuration, not ruleset data (ADR-050).
The issuer identifier and metadata
The issuer identifier is canopy-web’s public origin plus /identity: https://web.canopy.test:<port>/identity on the devstack. It must be an absolute https URL whose path is exactly /identity, written in canonical form; boot names the canonical spelling when it is not (crates/canopy-auth/src/identity_url.rs). Every token’s iss is that exact string, and every client assertion’s aud.
-
The public routes reach canopy-security through canopy-web. canopy-web is the only internet-facing service, so its edge (
EdgeForwarder,crates/canopy-auth/src/identity_edge.rs) forwardsPOST /identity/token,/identity/revokeand/identity/device_authorization, andGET /identity/jwksand the metadata, to their twins under the internal URL. The edge holds no credential and parses no form. It forwards only the body,Content-TypeandDPoP, and setsX-Forwarded-Forto the one client it resolves, overwriting any the client sent (Deployment Guide › The proxy chain). -
Inside the network every service uses the internal URL,
http://canopy-security:8012/identityon the devstack: a receiver fetches{internal}/jwks, a sender posts{internal}/token. -
The metadata is
GET /.well-known/oauth-authorization-server/identity(RFC 8414 §3.1). It names the issuer,token_endpoint,jwks_uriandrevocation_endpoint; the grantsclient_credentials, the RFC 8693 grant,device_codeandrefresh_token; the token endpoint’s client authentication,private_key_jwtornone(canopy-cli, which proves its key by DPoP instead); ES256 for client assertions and DPoP proofs; anddevice_authorization_endpointwhile the device flow is served (services/canopy-security/src/identity/token_endpoint.rs). While the issuer is unconfigured it answers 503temporarily_unavailable. -
The tokens are ES256 compact JWS with
typat+jwt. A token’saudis the one receiving service’s URI,urn:canopy:service:<service>, such asurn:canopy:service:canopy-persons(service_audience,crates/canopy-auth/src/identity_policy.rs).
The upstream profile
The deployment’s one upstream (ADR-049 §1) is described by one file, <CANOPY_CONFIG_ROOT>/identity-upstream.yaml (ADR-049 Amendment 5). Its fields and refusals are in Configuration Reference › the upstream identity profile. canopy-security and canopy-web read the same file, mounted read-only:
-
canopy-security’s federation grant verifies and projects the upstream’s id_tokens under it (canopy-identity’s federation grant). With no file, canopy-security logs one warning and serves no federation (
federation_unconfigured). -
canopy-web’s relying party signs workers in under it, and canopy-web refuses to boot without it (
services/canopy-web/src/auth/boot.rs).
The rules every upstream meets:
-
Profiles. Each vendor profile presets everything but the issuer, the client and the optional endpoints and trust anchors (ADR-049 Amendment 26, AL1):
-
kanidm, the default upstream (ADR-050), andkeycloak:ES256, claims from the id_token, a refresh that reissues it,client_secret_basic, the scopesopenidandprofile, and the claim pointers/roles,/primary_programsand/preferred_username. The roles and programs claims are canopy’s provisioning convention for each product, not built-ins, so the deployment must provision them under those names (The supported upstreams). -
zitadel:RS256, the same claim source, refresh and client authentication, ZITADEL’s project-roles and organisation scopes, and ZITADEL’s own claims. Roles and programs are the keys of the project-roles claim that the profile’s organisation granted, the programs asprogram_<wire id>(AL3). Azitadelfile also namesproject_idandorganization_id. -
oidc-genericstates every field, for a jurisdiction’s own OpenID Connect provider.
-
-
The issuer is one exact string. An id_token’s
issand discovery’sissuermust equal the configuredissuerbyte for byte, so write it as the IdP publishes it. A bare origin may omit its trailing/. -
Name each endpoint the IdP publishes on another origin. canopy-identity uses discovery’s
jwks_urianduserinfo_endpointonly when they pass the endpoint rule and share the issuer’s origin (scheme, host and port); if either fails, the whole key fetch fails and the upstream’s keys are unavailable, even for a profile that reads nothing from userinfo. Google, for example, publishes its JWKS onwww.googleapis.comand its userinfo endpoint onopenidconnect.googleapis.com, off its issuerhttps://accounts.google.com, so a Google profile names both (Configuration Reference › Endpoints on another origin). -
TLS trust anchors. A deployment that fronts its IdP with an internal PKI names a PEM bundle in
tls_trust_anchors, beside the profile. The upstream client then trusts only that bundle, never the built-in public roots, so a mis-issued public certificate cannot stand in for the IdP (ADR-049 Amendment 5; ADR-050 Amendment 2). Without one, it trusts the built-in roots. -
No request at boot. Boot validates the profile and makes no request to the upstream (ADR-049 §2): discovery and keys are fetched when first needed.
-
Userinfo answers plain JSON for the verified subject. canopy-identity calls the IdP’s userinfo endpoint (the profile’s
userinfo_endpoint, else discovery’s) with the upstream access token canopy-web forwards, as an RFC 6750 Bearer credential, and accepts only a 200application/jsonanswer of at most 64 KiB that is a JSON object in which no object, at any depth, names a member twice, and whosesubis the verified id_token’s, byte for byte (OIDC Core §5.3.2). A signedapplication/jwtanswer is refused, so the IdP must serve userinfo unsigned. Every other result is one of three outcomes (ADR-049 Amendment 5): unavailable (no connection, any timeout, the connection lost after sending, 408, 425, 429, a 5xx, or discovery down when the profile names no endpoint) lets an existing session renew within its grace and fails a sign-in; refused (any other 4xx) and invalid (any other answer, or no userinfo endpoint anywhere) end the session. -
The claims project to roles, programs and a username, or to a refusal code. canopy-identity reads the claims from the verified id_token, or from userinfo when the profile’s
claims_fromsays so, through the profile’s three pointers (ADR-049 Amendment 5;canopy_auth::upstream::project). An id_token or userinfo answer in which any object, at any depth, names a member twice is refused before anything is read, so a nested pointer such as/realm_access/rolescannot resolve to either of two values. The roles claim must be an array of strings, or underzitadelan object whose counted keys are its names: the names in canopy’s role vocabulary (ROLE_VOCABULARY,crates/canopy-auth/src/roles.rs) are granted, a name startingservice:never is, and every other name, such as an IdP default group, is ignored. The programs claim must be an array of program wire ids (snap,tanf,medicaid,chip,caps,wic),chipandmedicaiddistinct and never canonicalized into each other. The username claim must be a string of 1 to 256 bytes with no control character. A name listed twice is granted once; an object names each key once. A refusal carries a code, the first that applies in this order:Code Cause no_roleThe roles claim is absent, is not an array of strings (under
zitadel, not an object), or holds no vocabulary role (service markers, unknown names and keys another organisation granted do not count).missing_primary_programsThe programs claim is absent, or an empty array (under
zitadel, no countedprogram_key) (ADR-044). Kanidm omits a claim-map claim for a person in none of its groups, so a worker with no program group lands here.malformed_primary_programsThe programs claim is not an array (
nullincluded), or holds an element that is not a program wire id: another case (SNAP), a padded or unknown slug, or a non-string (ADR-044). Underzitadel, a countedprogram_key whose remainder is no wire id.no_usernameThe username claim is absent, not a string, empty, longer than 256 bytes, or holds a control character.
-
A cache in front of the upstream must send
Age. canopy-identity refreshes the upstream’s discovery and keys every 300 s, sendsCache-Control: no-cacheon each fetch, dates a key set by its fetch start less the response’sAge, and fails closed once the set is 720 s stale (ADR-049 Amendment 5;crates/canopy-auth/src/key_cache.rs). That bound holds only if every HTTP cache or CDN between canopy and the IdP sendsAgeon a response it serves from storage, as RFC 9111 §5.1 requires. A cache that omitsAgemakes a stored key set look fresh, so a key the IdP removed could keep verifying past 720 s. SendingAgeis the deployment’s requirement.
What an upstream must deliver
Whatever the product, the upstream must deliver all of the following. Kanidm, Keycloak and ZITADEL, provisioned as The supported upstreams describes, do; each one’s conformance suite proves it against a disposable server (Local Development › The conformance server, Keycloak’s and ZITADEL’s).
-
Discovery. A document at
{issuer}/.well-known/openid-configurationwhoseissueris exactly the profile’s, namingauthorization_endpoint,token_endpointandjwks_urion the issuer’s origin, or the profile names them (The upstream profile). Auserinfo_endpointtoo when the profile reads claims or renewals from userinfo. -
The authorization code flow for one confidential client. The client is canopy-web’s (Registering canopy’s clients), authenticating at the token endpoint by the profile’s
client_auth_method,client_secret_basicorclient_secret_post. canopy-web sends a fresh 256-bitstateandnonce, an S256 PKCE challenge and the profile’s scopes, which holdopenid(UpstreamRelyingParty::authorization). The upstream must accept PKCE S256 and return thenoncein the id_token. -
Registered redirects.
{origin}/auth/callbackfor every canopy-web public origin (CANOPY_WEB__PUBLIC_ORIGIN), and{origin}/loginas the post-logout redirect when the upstream has an end-session endpoint. Register them exactly; a production deployment registers a static list. -
id_tokens canopy can verify (ADR-049 Amendment 5;
crates/canopy-auth/src/upstream/id_token.rs). Signed with an algorithm the profile allows, under akidthe JWKS publishes, with a headertyp, when present, ofJWTorapplication/jwt.audis exactly the client id (a string, or an array holding only it), andazp, when present, is the client id. Azitadelprofile admits one moreaud: an array of exactly the client id and itsproject_id, withazpthe client id.subis stable, 1 to 255 ASCII bytes with no control character.exp,iatandauth_timeare present, andiatis at most 300 s old when canopy verifies it.amrandacrare never read. -
auth_time,prompt=loginandmax_age. canopy-web asks forauth_timeas an essential id_token claim on every authorization request (the OIDC Core §5.5claimsparameter), because OIDC lets a provider omit it otherwise. None of the three verified upstreams depends on the request: each sendsauth_timeunasked, and Keycloak only through itsbasicclient scope, which the request does not replace (Keycloak (keycloak)). The upstream must honour two more parameters:-
prompt=login, sent on the first sign-in after a sign-out and on the one retry after a stale sign-in. canopy-identity refuses to open a session that would end within 900 s,auth_time_too_old: a web session endsIDENTITY_WEB_SESSION_MAX_SECONDS(12 h by default) afterauth_time, so an upstream single sign-on session within 900 s of that age must re-authenticate the worker. -
max_age, sent on a step-up: 300 s (STEP_UP_MAX_AGE,step_up_options()incrates/canopy-auth/src/identity_admin/client.rs). canopy-web refuses an id_token whoseauth_timeis outsidemax_ageplus 60 s, and restarts the flow once withprompt=login. canopy-security’s security-admin routes and the device approval accept a sign-in at most 600 s old (SECURITY_ADMIN_MAX_AGE_SECONDS,DEVICE_APPROVAL_MAX_AGE_SECONDS). ZITADEL ignoresmax_age(ZITADEL (zitadel)), so on ZITADEL that refusal and retry are what enforce a step-up’s freshness.
-
-
The claims, mapped in the IdP. Worker roles, spelled as canopy’s role vocabulary, at the profile’s roles pointer; the worker’s programs as wire ids at its programs pointer; a username at its username pointer. canopy maps no roles or programs itself (ADR-044): map the upstream’s groups onto canopy’s names in the IdP. On Kanidm, roles and programs are groups (
canopy_role_*,canopy_program_*) projected into the id_token by thecanopy-webclient’s claim maps (Local Development › Upstream IdP: Kanidm). -
A refresh token. A session is fresh for 900 s after its last upstream validation (ADR-049 §6), and canopy-web renews it only from an upstream refresh. Without a refresh token a session cannot be renewed, so it ends when that freshness lapses. Under
refresh: reissues_id_token, every refresh answer carries a new id_token with the session’siss,suband originalauth_timeand a neweriat; underrefresh: userinfo, userinfo answers for the refreshed access token (canopy-identity’s federation grant). A rotating refresh token is safe: canopy-web never presents one twice (Keeping a session fresh). -
Optional endpoints. An RFC 7009
revocation_endpoint, where canopy-web revokes the upstream refresh token at sign-out, and an RP-Initiated Logoutend_session_endpoint. Without the latter, canopy-web signs the worker out locally and sendsprompt=loginon the next sign-in, so the upstream’s single sign-on session cannot sign the worker straight back in. Kanidm advertises no end-session endpoint (ADR-050).
Four obligations canopy cannot check:
-
Multi-factor authentication for every worker. canopy reads no
acroramrclaim. Where each supported upstream enforces it is in The supported upstreams (AL4). -
substability. canopy links each exact (issuer,sub) pair to one canopy subject, so a newsub, or a renamed issuer, is a new subject until a security administrator re-links it (Security Operations › Re-linking an upstream identity). -
Deprovisioning. A worker removed upstream must have their next refresh refused: the upstream’s refusal ends the session, and canopy-web renews at least every 900 s. To end access sooner, suspend the worker’s subject and revoke their sessions at canopy-web’s
/admin/security; a delegation token already minted lives at most 300 s more (Security Operations › Subjects and web sessions). -
Role and program mapping in the IdP, as above.
The supported upstreams
Three products are verified upstreams, each with its profile and conformance suite (ADR-050, Amendments 3, 5 and 6; ADR-048 Amendment 2). Each runs at the version its suite verified; a version bump is a change with its suite (cargo xtask identity conformance --idp <idp>). For each: a setup checklist, the profile skeleton, where MFA is enforced, and what it does that canopy relies on knowing. The devstack provisions all three this way (Local Development › The devstack’s upstream), so its provisioning code is a working reference.
Kanidm (kanidm, the default)
-
Version: 1.12.2.
-
Checklist.
-
Persons, the groups
canopy_role_<role>andcanopy_program_<wire id>, and thecanopy-webOAuth2 client, whose claim maps project the groups asrolesandprimary_programs(the devstack’s cast file,devstack/kanidm/migrations/00-canopy.hjson). -
canopy-web’s origins'
/auth/callbackregistered as the client’s redirects. -
Each person’s password and TOTP.
-
-
Profile:
profile: kanidm issuer: https://idm.example.org/oauth2/openid/canopy-web client_id: canopy-web -
MFA: Kanidm’s credential policy for
idm_all_personsrequires it: Kanidm refuses to commit a password-only credential, which its suite tests. -
Behaviour:
-
No end-session endpoint: canopy-web revokes the refresh token at sign-out.
-
A refreshed id_token repeats the
nonce. -
auth_timecomes unasked, though Kanidm does not document it. -
Refresh replay is judged in whole seconds (ADR-050 Amendment 1). Replaying a token superseded in an earlier second is refused and revokes the session. Replaying one that was issued and rotated within a single second is accepted, which forks the session. The suite pins both cases.
-
Keycloak (keycloak)
-
Version: 26.8.2.
-
Checklist (ADR-049 Amendment 26; the devstack’s realm,
devstack/keycloak/realm.json, is a template with no secrets):-
A realm with an ECDSA P-256 key provider and
defaultSignatureAlgorithm: ES256. -
A TOTP policy (the devstack uses HmacSHA256, 6 digits, 30 s). Keep Keycloak’s single-use default: only the devstack’s realm sets
otpPolicyCodeReusable. -
A browser flow, a copy of
browserwhose OTP Form is REQUIRED rather than conditional, bound as the realm’s browser flow. Also a direct-grant flow that requires the OTP, since Keycloak gives every realmadmin-cli, whose password grant would otherwise skip it. -
CONFIGURE_TOTPdisabled. Otherwise an account without an OTP credential could enrol one on its password alone. Enrol each worker’s OTP credential administratively instead. -
primary_programsdeclared in the user profile (Keycloak 24+ refuses unmanaged attributes), and realm roles named as canopy’s role vocabulary. -
The client
canopy-web:-
confidential, standard flow only, PKCE S256 required;
-
redirect URIs each canopy-web origin’s
/auth/callback, andpost.logout.redirect.uriseach origin’s/login; -
default client scopes
basic(subandauth_time; never remove it, see the behaviour below),profile, and acanopyscope whose realm-role mapper writesrolesand whose user-attribute mapper writesprimary_programs, both multivalued, in the id_token and userinfo, never the access token.
-
-
-
Profile:
profile: keycloak issuer: https://idm.example.org/realms/canopy client_id: canopy-web -
MFA: in the server. The required OTP form refuses an account without an OTP credential ("credential setup required"), in the browser and by a password grant.
-
Behaviour:
-
RP-initiated logout returns to
/loginand ends the SSO session. -
A refreshed id_token omits the
nonce, which canopy accepts. -
One session per browser sign-in: every token of one sign-in shares one Keycloak session, so revoking one refresh token ends the others. Revoking a device’s upstream token, which a native session holds from its step-up, also ends the web sign-in that step-up rode.
-
Keycloak has no account expiry: disable an account to end its refresh.
-
auth_timecomes only from thebasicclient scope. Its session-note mapper is Keycloak 25+'s only source ofauth_time, and ofsubas well. A client withoutbasicgets an id_token with neither, even though canopy-web asks forauth_timeas an essential claim and discovery advertisesclaims_parameter_supported. Every sign-in then fails canopy's id_token check. The suite pins this (auth_time_comes_only_from_the_basic_scope_even_when_asked_as_essential, #3256).
-
ZITADEL (zitadel)
-
Version: v4.21.0, with Login V2 as the login client.
-
Checklist (AL3, AL4):
-
The login policy forces MFA, with TOTP an allowed second factor.
-
A project with
projectRoleAssertion, whose roles are canopy’s role vocabulary plusprogram_<wire id>per program (program_snap). -
An OIDC web application
canopy-webin that project, and alone in it, soaudholds only the client and the project:-
code flow with the refresh-token grant,
client_secret_basic; -
idTokenRoleAssertionandidTokenUserinfoAssertionon; -
redirect URIs each canopy-web origin’s
/auth/callback, and post-logout redirect URIs each origin’s/login.
-
-
Store the application’s client secret when it is created: ZITADEL shows it once.
-
Grant each worker its roles and programs in the organisation the profile names. A grant from another organisation counts for nothing.
-
Enrol each worker’s TOTP administratively at creation. With MFA forced, Login V2 sends an account with no second factor to set one up after its password, so whoever holds a new account’s initial password could enrol it.
-
Protect Login V2’s credential (its personal access token) as ZITADEL’s administrator credential. The core leaves factor sufficiency to its login client, so anything holding that token can finalize a sign-in without MFA.
-
-
Profile (the ids are strings, so quote them):
profile: zitadel issuer: https://idm.example.org client_id: "312909075212468632" project_id: "312909075212402200" organization_id: "312909075212336664" -
MFA: in Login V2, the trusted login client, never in ZITADEL’s core.
-
Behaviour:
-
RP-initiated logout returns to
/loginand ends the session, but its refresh tokens survive it. canopy-web therefore revokes the session’s refresh token at sign-out as well (#2905). -
ZITADEL ignores
max_age, in Login V2 and in the core (zitadel/zitadel#12258). A step-up whosemax_agethe worker’s ZITADEL session has outlived is answered from that session, with its earlierauth_time. canopy-web refuses thatauth_timeand retries once withprompt=login, which Login V2 honours. The worker signs in again, one redirect later than on Keycloak. The ZITADEL suite and browser spec pin this, and #2906 tracks the upstream fix. Do not rely onmax_agealone in any other relying party on the same ZITADEL. -
A TOTP code is single-use (
TOTP-Auw0a). -
A revoked refresh token, or a deactivated account’s, is refused
invalid_request, and canopy ends the session on any 4xx. -
Refresh tokens rotate. Each refresh answers a new refresh token, and the one it replaced is refused from then on: 400
invalid_request,Errors.OIDCSession.RefreshTokenInvalid. Unlike Kanidm's, a replay does not revoke the session, and the newest token still refreshes. The suite pins this (#3256). canopy-web never presents a refresh token twice (Keeping a session fresh). -
auth_timecomes unasked. ZITADEL documents it in its claims reference.
-
Registering canopy’s clients
At the upstream: canopy-web. Register one confidential client for canopy-web, with the redirects above. Its id is the profile’s client_id (on Kanidm the issuer’s last path segment too, /oauth2/openid/canopy-web; on ZITADEL the application’s generated client id), and its secret reaches canopy-web as CANOPY_WEB__UPSTREAM_CLIENT_SECRET, a reserved key read through the secret provider with no file fallback. No other canopy component is an upstream client. On the devstack, provisioning creates or declares the client and xtask registers its redirects at every bring-up, whichever upstream runs (Local Development › The devstack’s upstream).
At canopy-identity: the confidential clients. Fifteen confidential clients authenticate to the token endpoint with a private_key_jwt assertion (RFC 7523) signed by an ES256 key: canopy-web, canopy-portal, and the thirteen services that call another service. identity-clients.yaml registers each one’s public key, or two during a rotation, and its token-request rate (Configuration Reference › the client registry). Each client holds its private key as CANOPY_<SVC>__IDENTITY_CLIENT_PRIVATE_KEY and refuses to boot without it. canopy-cli is a native client: public, with no registry entry, its refresh credential bound to a DPoP key it holds.
Client ids, the call graph and each system token’s purpose are code, not configuration (crates/canopy-auth/src/identity_policy/). A client may mint only for a target its compiled edge names, and a receiver refuses a token whose last hop has no edge. cargo xtask call-graph check holds the compiled graph to the peer URL settings and to its generated table (Authorization Inventory › Compiled call graph).
canopy-web’s sign-in
canopy-web signs a worker in at the upstream through its relying party, has canopy-identity federate the answer into a session, and keeps that session with the upstream grant in its own database (services/canopy-web/src/auth/, web_session/).
| Route | Behaviour |
|---|---|
|
The sign-in page: the jurisdiction’s system-use notice (AC-8, |
|
Creates a sign-in flow and redirects to the upstream. A plain navigation, as every step toward the upstream is: the CSP’s |
|
Creates a step-up flow ( |
|
Takes the flow, completes it by kind (a sign-in, a step-up or a device approval) and answers the handoff page to the flow’s return path, never a redirect (Cross-site upstreams). |
|
CSRF-checked. Ends the session row, revokes canopy-identity’s session and the upstream refresh token, then hands off to the upstream’s end-session endpoint with the id_token as its hint, or to |
A flow is a web_login_flow row, 900 s, holding the state hash, the nonce, the PKCE verifier, any max_age and the return path, and named by the __Host-canopy_login_flow cookie. The callback takes it once, with the state the upstream returned, redeems the code within 10 s (UPSTREAM_TOKEN_TIMEOUT, discovery and the key fetch included), checks the id_token and its nonce, and presents it to canopy-identity’s federation grant. A stale sign-in, auth_time_too_old, restarts the flow once with prompt=login.
A refused sign-in renders the sign-in page with one message, chosen by code (services/canopy-web/src/auth/refusal.rs):
| Code | Cause |
|---|---|
|
The projection’s refusals (The upstream profile), or canopy-web’s own admission finding no role or no scopable program. Fix the IdP’s claim mapping. |
|
A security administrator suspended the worker’s subject. |
|
The upstream refused the sign-in, or ended its grant. |
|
The upstream’s authentication stayed too old after the one |
|
canopy-identity could not be reached, or answered unavailable. |
|
A device approval’s code is not valid, or its step-up signed in as someone else (Device approval and native sessions). |
|
Anything else: the upstream’s answer did not verify, or the flow named nothing to complete. canopy-web’s log names the failure. |
Cross-site upstreams
canopy-web signs workers in through an upstream on any registrable domain: a hosted one (Login.gov, Entra ID, Okta, a state’s shared IdP) as well as one beside it (#2509). The upstream returns the browser to /auth/callback by a navigation its own page starts, which is cross-site when the upstream is on another registrable domain. A browser sends SameSite=Lax cookies on such a navigation and withholds SameSite=Strict ones, so sign-in depends on no Strict cookie:
-
The flow travels in the Lax flow cookie.
__Host-canopy_login_flowisHttpOnly,SameSite=Lax, 900 s. The callback reads nothing from the session cookie. A device approval stores the approving worker’s session id in its flow for the same reason. -
The callback answers a handoff page. A completed flow answers
200 text/html, never a redirect (services/canopy-web/src/auth/handoff.rs). The page sets the new session cookie and sends the browser on, by a<meta http-equiv="refresh">and a Continue link, to the flow’s stored return path, validated again, or/. That navigation starts from canopy-web’s own page, so it is same-site and carries the session cookie. The page sendsCache-Control: no-storeandReferrer-Policy: no-referrer.
The session cookie, __Host-canopy_session, stays SameSite=Strict: it is the CSRF control for the composition API. The e2e suite signs in through a second canopy-web on another registrable domain than the devstack’s Kanidm (Local Development › The cross-site sign-in instance).
Keeping a session fresh
A worker’s web session is canopy-identity’s federated session plus the upstream grant that keeps it fresh, one WebSessionRecord in canopy-web’s web_session row (ADR-049 Amendment 18; crates/canopy-auth/src/identity_web_session.rs). canopy-web maintains a session 120 s before canopy-identity’s fresh_until and at least every 780 s, so it is re-federated at least every 900 s. Maintenance refreshes the upstream grant, then renews canopy-identity’s session with the evidence the profile names (canopy-identity’s federation grant).
A refresh is sorted by whether the upstream may have processed it, and so spent the token, because a rotating issuer revokes the whole token family when a spent token comes back (ADR-049 Amendment 2; RefreshFailure, crates/canopy-auth/src/upstream/relying_party/session.rs):
-
Not processed keeps the session, which may take grace: the token was never presented (discovery or the token endpoint unavailable, no connection, a connect timed out at its 2 s bound), or the upstream answered 408, 425 or 429.
-
Ended ends the session, and its token is never presented again: a refusal (any other 4xx), a 200 it cannot read, a request timeout, a connection lost after it opened, a 5xx, a 3xx or any other status.
Single flight across replicas (#2224). A session’s refresh token is presented only under a claim committed in its row first, leased 60 s (CLAIM_LEASE), and a commit lands only under that claim. So across every replica a refresh token is presented at most once, and a rotating issuer never sees a replay. A claim whose lease lapsed is never cleared: the next request ends the session as refresh_lost, one sign-in rather than a replay. These guarantees assume acknowledged commits survive a failover (Deployment Guide › Worker sessions under replication).
canopy-identity’s federation grant
canopy-identity’s token endpoint serves an RFC 8693 grant by which canopy-web turns a sign-in at the upstream into a canopy web session, and keeps it fresh (ADR-049 §6, Amendment 6; the wire contract is canopy-security’s API › POST /identity/token). Without a profile the federation forms are invalid_request (federation_unconfigured); the grant itself stays served, and listed in the metadata, for the delegation mint.
-
Only canopy-web, by its own key. canopy-web authenticates with a
private_key_jwtassertion signed by the key the client registry binds tocanopy-web; any other authenticated client isunauthorized_clientbefore canopy-identity looks anything up or calls the upstream. -
The upstream is judged again. canopy-web presents the id_token it verified at sign-in; canopy-identity verifies it again under the profile, and, when the profile’s claims come from userinfo, calls userinfo with the access token canopy-web forwards, bound to the id_token’s
sub. It projects the claims (The upstream profile), so the roles, programs and username a session carries are the ones the profile’s pointers read, refused with the projection’s code otherwise. -
One canopy subject per upstream identity. The first open of an unseen pair of the profile’s exact
issuerand the id_token’ssubmints a canopy subject (a UUID v7) and links the pair to it; every later open of that pair is that subject’s. A renamed IdP client that changes theissuerstring therefore mints a new subject until a security administrator re-links it. A suspended subject’s open is refused (subject_suspended). -
The session. It ends
IDENTITY_WEB_SESSION_MAX_SECONDSafter the upstreamauth_time(default 12 h; Configuration Reference) and is fresh for 900 s from the id_token’siat. A sign-in whose session would end within 900 s is refusedauth_time_too_old, so canopy-web re-authenticates withprompt=login. The answer’saccess_tokenis the session’s opaque credential, which canopy-identity stores only as its SHA-256;subis the canopy subject, never the upstream’s. -
Unavailability fails the sign-in. Unreachable discovery, keys or userinfo answer 503
temporarily_unavailable, and so does a userinfo endpoint named nowhere or refused by the client, a deployment defect logged as such. A refusal canopy-web must act on carriescanopy_refusal(the projection codes,auth_time_too_old,subject_suspended,upstream_refused);upstream_refusednames only the upstream’s own verdict (userinfo refused the access token, or answered invalidly), never canopy’s (ADR-049 Amendment 6). canopy-web allows the grant its whole deadline, 13 s (TOKEN_EXCHANGE_DEADLINE): a cold upstream may take three sequential 2.5 s calls before the answer. -
Renewal. The session is fresh until its answer’s
fresh_until, 900 s after the last upstream validation. canopy-web renews after each upstream refresh, and at least every 900 s, with the session’s credential and the evidence the profile’srefreshnames: the refreshed id_token underreissues_id_token, or the upstream access token underuserinfo. canopy-identity holds a refreshed id_token to the session’s upstreamiss,suband originalauth_time, the original nonce or none, and aniatnewer than the last it recorded; the same id_token again is a replay, which answers the session as it stands. A userinfo renewal is bound to the session’s upstreamsub. Each recorded renewal re-projects, so the session’s roles and programs follow the upstream. A session belongs to the upstream issuer and client it opened under: a profile that names another revokes the session at its next renewal (upstream_changed), before any upstream call, and canopy-web signs the person in again. -
Grace. When canopy-web could not process the upstream’s refresh (Keeping a session fresh), it sends
upstream_outcome=not_processedin place of the evidence; canopy-identity grants the same grace when its own userinfo call or key fetch is unavailable. A grace holds the session fresh until the last successful upstream validation + 900 s +IDENTITY_SESSION_GRACE_SECONDS(default 1800, at most 3600), never past the session’s end, and a second grace before the next success ends where the first did. Each grace is recorded in the issuance log. Past that window a grace is refusedgrace_exhausted. -
How canopy-web treats each renewal answer. A 200 carries the session’s terms: canopy-web keeps the credential (echoed, never rotated) and takes
fresh_until,roles,programsandusernamefrom it.session_ended,upstream_refused, a projection code andsubject_suspendedend the session, and canopy-web signs the person in again (subject_suspendedrefuses that sign-in too).grace_exhaustedchanges nothing: the session lapses at itsfresh_until, and a renewal with real evidence may still succeed.invalid_requestwith nocanopy_refusal, or a 503, changes nothing either: canopy-web lets the session lapse at its recordedfresh_untiland may renew again before then.
Device approval and native sessions
canopy-cli signs a worker in by RFC 8628’s device flow, and canopy-web approves it (ADR-049 §7, Amendment 9, Amendment 21; the wire contract is canopy-security’s API). Every route here needs an upstream profile; the two device routes need CANOPY_SECURITY__IDENTITY_DEVICE_VERIFICATION_URI too, canopy-web’s {origin}/device.
-
Code entry.
canopy loginprints the verification URI and a user code (XXXX-XXXX, case and separators ignored). The worker, signed in to canopy-web, enters it at/device(services/canopy-web/src/device.rs), which posts it toPOST /identity/device_verificationwith canopy-web’s assertion and the worker’s web-session credential:action=describeanswers the device’s client and times for the confirmation page, andaction=denyrecords a denial, which canopy-cli’s polls then answeraccess_denied. A code no device holds, or one expired, decided or malformed, or canopy-cli disabled, isuser_code_invalid; canopy-web shows one message for them all. -
Step-up, then approval. To approve, canopy-web obtains a fresh sign-in for a dedicated upstream grant (
step_up_options()) and presents its id_token, with the user code and the approving worker’s web-session credential, as the approval (requested_token_type=urn:canopy:params:oauth:token-type:native-revalidation). The issuer holds the approval to that worker (ADR-049 Amendment 21): a step-up signed in as anyone else isapprover_mismatch, nothing is approved, and the device stays pending. A sign-in more than 600 s old isauth_time_too_old, so canopy-web asks again. A suspended subject is refused. -
Attempts. Each describe, denial and approval spends one of the worker’s attempts: 10 at once and one more a minute, per replica, keyed by the worker’s upstream issuer and subject. Past it, each is a 429 with
Retry-After, before the code is read; canopy-web tells the worker to wait. -
The native session. The approval’s
access_tokenis the revalidation credential: canopy-web keeps it with the dedicated grant, never hands it to canopy-cli, and presents it only to renew the session. canopy-cli gets its own DPoP-bound refresh credential when it redeems its device code. The session endsIDENTITY_NATIVE_SESSION_MAX_SECONDSafter the step-up sign-in (default 8 h, at most 24 h). -
Renewal and revocation. canopy-web re-federates the native session as it does a web session, from the dedicated grant’s refreshes, at least every 900 s (
NativeSessions::sweep, every 30 s). A native session past its freshness mints nothing for canopy-cli (session_stale) until canopy-web renews it. A worker revokes a device at/device/sessions; canopy-cli’scanopy logoutrevokes the session by its refresh credential. A session canopy-cli never redeemed before its device code expired is revoked at its next renewal. -
canopy-cli’s side (
canopy_auth::DeviceClient, ADR-049 Amendment 23).canopy loginpolls per RFC 8628 until the worker decides, then stores the session in the profile’s owner-only device store;canopy token <SERVICE>prints a token for one service, refreshing under the store’s lock so concurrent invocations never present one credential twice;canopy logoutrevokes and removes the session. A profile names its issuer (identity_issuer, the public issuer), and a session stored under another issuer answersLoginRequired, so a moved issuer asks forcanopy loginagain (canopy CLI Reference).
Gating a deploy: canopy-manage identity check
canopy-manage identity check --issuer <identifier> --internal <url> [--client <id>] is canopy-identity’s deploy gate (ADR-049 Amendment 23; tools/canopy-manage/src/identity_check.rs). It ships in the service image (canopy-manage Reference). It runs three checks against the internal URL, in order, and a failure names its check:
-
metadata — the RFC 8414 document names the issuer identifier exactly and names the token, revocation and JWKS endpoints, and those three, with the device authorization endpoint when served, lie under the issuer identifier (the same origin, a path below it); other members are not read;
-
keys — the JWKS holds at least one ES256 P-256 signing key whose kid is its RFC 7638 thumbprint;
-
mint — one client-credentials grant by
--client(defaultcanopy-eligibility) for its first compiled purpose validates at that purpose’s receiver as a receiver validates it, and the principal is a system token naming that client, that purpose and exactly the purpose’s scopes.
A client with no compiled purpose is refused before anything is sent, and the grant is the gate’s only side effect, so it is safe against production. The client’s key is read through the audited secret provider from CANOPY_<SERVICE>__IDENTITY_CLIENT_PRIVATE_KEY (client_key_secret). There is no other source: the gate signs as that service, so run it where the service’s key already is, and an unset variable is refused by name. Both URLs must be https; http is admitted only when CANOPY_ENV=development, the rule a service’s own boot applies to the same two settings.
The upstream itself is checked by its conformance suite, all three by cargo xtask identity matrix before an identity push and on a release tag (Local Development › the identity matrix). canopy-web’s sign-in is checked by the e2e suite’s real redirect chain through each upstream’s own pages (Testing › The identity-plane project).
Keys and rotation
-
canopy-identity’s signing keys are per replica, held in memory only, and rotate on their own; receivers refresh the published set every 300 s, refetch on an unknown kid, and fail closed once their set is 720 s stale. Procedures, emergency revocation included: Security Operations › canopy-identity signing keys.
-
Client keys rotate by registering a second key: Security Operations › canopy-identity client keys.
-
The upstream’s keys need no canopy action. canopy-identity and canopy-web refetch the upstream’s keys on an unknown kid and every 300 s, and a key the IdP removes stops verifying within 720 s (The upstream profile).
-
canopy-web’s upstream client secret rotates at the upstream first, then reaches canopy-web as
CANOPY_WEB__UPSTREAM_CLIENT_SECRETwith a rolling restart (Secret Management).
Troubleshooting
| Symptom | Likely cause |
|---|---|
A service refuses to boot naming |
The setting is missing, not |
A service refuses to boot naming |
The client key is unset, blank, or not an unencrypted PKCS#8 P-256 PEM. No file stands in, in any environment. |
canopy-web refuses to boot naming the upstream profile, its trust anchors or |
|
The sign-in redirect lands on a 404 or an unreachable host |
The upstream’s |
The upstream answers the authorization request with a redirect-URI error |
|
Sign-in ends on |
The IdP’s claim mapping: only vocabulary role names survive projection, programs must be wire ids, and the pointers must address where the IdP puts them (The upstream profile). |
Sign-in ends on |
The upstream ignored |
Sign-in ends on |
The id_token did not verify: an issuer string that differs from the profile’s, an |
canopy-web’s federation is answered |
canopy-security has no upstream profile mounted at its config root. |
A service’s calls fail with the token endpoint’s |
No registered key matches the client’s assertion |
Receivers answer 401 |
|
A step-up on ZITADEL shows Login V2’s sign-in after an extra redirect |
ZITADEL ignored the step-up’s |
Sign-out continues to |
The upstream advertises no |
Sign-out answers 403 |
The page’s sign-out form carries a CSRF token that is no longer the session’s: the page was rendered before the worker signed in again in another tab. Reload the page and sign out again. |
Implementation references
-
crates/canopy-auth/src/upstream/— the upstream profile (profile.rs), its id_token validator (id_token.rs), userinfo, the projection (projection.rs), the key source and canopy-web’s relying party (relying_party.rs). -
crates/canopy-auth/src/identity_web_session/— canopy-web’s session engine and its store contract;crates/canopy-auth/src/identity_client/federation.rs— the federation client. -
services/canopy-web/src/auth/— the sign-in routes, the handoff page and the refusal codes;services/canopy-web/src/web_session/— the session store;services/canopy-web/src/device.rs— device approval. -
services/canopy-security/src/identity/token_endpoint.rsandtoken_endpoint/federation.rs— the token endpoint, its metadata and the federation grant. -
crates/canopy-auth/src/identity_edge.rs— canopy-web’s edge forwarder;crates/canopy-auth/src/identity_url.rs— the issuer’s mount rules. -
crates/canopy-auth/src/identity_policy/— the compiled clients, call graph and purposes. -
tools/canopy-manage/src/identity_check.rs—identity check(Gating a deploy:canopy-manage identity check);xtask/src/cmd/identity/conformance.rsandmatrix.rs— the conformance runs and the identity matrix. -
crates/canopy-test-lib/src/upstream/— each supported upstream’s provisioning and headless sign-in;crates/canopy-test-lib/tests/idp_conformance_*.rs— the conformance suites.