Identity plane split, plan I0: ADR-049, ADR-050 and the Kanidm upstream verification (epic &130)
Status: Done (2026-09-30) — !1543
Epic: &130 (identity plane split)
Issues: #2485 (w3), #2486 (w5), #2487 (w5), #2488 (w2)
Branches:
-
MR-1
docs/adr-049-identity-plane-split(U1). It carries this page. -
MR-2
feat/kanidm-upstream-conformance(U2, U3, U4), titled "Kanidm upstream profile, conformance suite and ADR-050 (#2486, #2487, #2488)". ADR-050’s evidence is U2 and U3’s output, so the three units ship together.
This is a Design + Scope plan. GitLab owns tracking. The plan freezes when U1 starts.
Erratum (2026-09-30): D2 and D3 are corrected to the as-built cache facts found in U1’s review. Delegation tokens are reused only within their request (ruling R4, ExchangeCache). Today’s subject_scoped_key covers audience, scopes and purpose, not roles and programs. The mitigation that D2 credits to caching is the system-token cache (ADR-037). The credentials file keeps secrets as zeroize::Zeroizing with a redacting Debug (the ServiceCredentials pattern), not secrecy::SecretString, which is not a workspace dependency.
Erratum (2026-09-30): U1’s security review tightened ADR-049, which is canonical from U1 on. The changes:
-
step-up is enforced by the issuer’s device-approval grant and the security-admin routes;
-
a system token is never a delegation subject token;
-
a federated id_token must be at most 5 minutes old, and canopy-web checks its
nonce; -
device codes get phishing mitigations (RFC 8628 §5.4);
-
a replica’s first key signs for at most 10 minutes, and the next key is inserted at least 60 s before
sign_until; -
the compromise response revokes every row inserted since the compromise;
-
the threat-model bounds are restated.
Erratum (2026-09-30): U2 and U3 differ from this page as built. The differences:
-
totp-litelands in U2, because enrolment answerstotpverify; -
lanes::CLIPPY_FEATURESand its validate wiring land in U3 with the feature; -
the command times an explicit
compose build, andstopleaves the container for the next run to remove; -
the scope map grants
idm_all_persons; -
the runtime image adds
ca-certificates; -
the realm usernames are kept, because Kanidm accepts
.and-; -
persons_are_offered_only_password_with_totpbecamea_person_cannot_commit_a_password_only_credential_and_is_offered_only_passwordmfa, which also proves that a password-only commit is refused; -
a default run removes its container, and the devstack’s own probes ignore opt-in services.
Context
-
Goal. Kanidm becomes canopy’s default human IdP. ZITADEL and Keycloak become first-class alternatives, and all three are tested.
-
Why today’s design cannot reach it. ADR-048 makes the IdP the one issuer for sign-in, both exchange hops, every receiver and every service token (§2, §5). Kanidm 1.11.2 cannot be that issuer. Each client gets its own issuer. Exchange takes service-account subjects only. Access tokens carry only standard claims, none of the mapped authorization claims. Client-credentials tokens are JWE. Tokens live a fixed 900 s. There is no password grant. (Source: https://github.com/kanidm/kanidm/blob/v1.11.2/server/lib/src/idm/oauth2.rs, lines 976-980, 1747-1850, 1858-1976 and 2040-2111.)
-
The other products. ZITADEL 4.19.3 hides the exchange grant and only narrows audiences. Keycloak works, but canopy has compiled Keycloak’s rules in:
-
aud-<target>scopes (services/canopy-portal/src/tokens.rs,services/canopy-eligibility/src/orchestrator.rs); -
the hop-2 audience pair (
crates/canopy-auth/src/receiver.rs); -
the harness password grant (
crates/canopy-test-lib/src/auth.rs, about 90 files).
-
-
Maintainer rulings (2026-09-29/30).
-
canopy runs its own issuer, hosted in canopy-security. The IdP authenticates humans only.
-
Calls act as the user, per hop. Background work uses purpose-scoped system tokens.
-
Keys are per-replica ES256, held in memory.
-
Native clients use the RFC 8628 device flow.
-
canopy mints its own subjects.
-
The IdP profile is deployment configuration.
-
There is no backward compatibility and no timing constraint.
-
-
Constraints in the tree.
-
Receivers trust one issuer, default to RS256 and ignore the JOSE
typ(crates/canopy-auth/src/jwks.rs). -
signing_key_historyis owned by the runtime role and has aSET LOCALbypass (services/canopy-security/migrations/20260624000000_create_signing_key_history.sql). -
The worker directory has no disabled flag.
-
Refresh single-flight is per process (
services/canopy-web/src/auth/refresh.rs). -
The devstack has no TLS.
-
An owner/runtime role split exists (
MIGRATION_DATABASE_URL,crates/canopy-api/src/bootstrap.rs; canopy-reporting uses it).
-
Scope
In scope:
-
ADR-049 (D1-D14) and its banners;
-
the opt-in Kanidm devstack profile and its provisioning;
-
the Kanidm conformance suite;
-
ADR-050 (E1-E5);
-
the GitLab filing below.
Out of scope:
-
building canopy-identity (I1, I2), the cut-over (I3) and the alternative profiles (I4);
-
the key and secret loader defects, which get their own issue;
-
each amended ADR’s detailed amendment, which lands with the stage that makes it true.
Design
ADR-049: the identity plane (U1)
| # | Decision |
|---|---|
D1 |
Two layers, one issuer each.
|
D2 |
canopy-identity is a module of canopy-security, not a new service.
|
D3 |
Credentials. Compact JWS, ES256 (pinned in code),
|
D4 |
Policy is code. The call graph (caller → target) and the purpose registry ((client, audience) → scopes) are compiled tables in canopy-auth, not jurisdiction configuration. The issuer applies them; receivers re-check |
D5 |
One trust root per credential, never shared.
|
D6 |
Worker sign-in (canopy-web).
|
D7 |
Native and machine clients.
|
D8 |
Subjects.
|
D9 |
Keys.
|
D10 |
Client auth is
|
D11 |
Applicant portal. It keeps its own applicant authentication; its per-target tokens become system tokens with portal purposes. |
D12 |
Revocation. canopy-security owns subject suspension (new), session revocation, client disablement and key revocation. Every mint checks them, so an in-flight token stays acceptable for at most 300 s (delegation) or 600 s (system), plus the 60 s leeway and 60 s skew. The admin routes need a security-admin role, are surfaced in canopy-web, and are audited. |
D13 |
Issuance audit. Every mint and refusal appends to an INSERT-only log in canopy-security’s DB, with group commit. A credential is released only after its row commits (fail-closed), keeping the audit-before-release contract of |
D14 |
Time and tests.
|
ADR-049 also carries:
-
a threat model: stolen credentials; a compromised service, canopy-web or upstream; a stolen runtime DB credential; a memory read;
-
the rejected alternatives: Kanidm as issuer, multi-issuer receivers, Keycloak as issuer, and the other custody options;
-
reopen triggers: separation of duties, a mandated HSM or FIPS module, and a source no single upstream can broker;
-
references: RFCs 6749, 7009, 7523, 7638, 8414, 8628, 8693, 8707, 9068 and 9449, OIDC Core, and the IETF Transaction Tokens draft;
-
the filing map below;
-
a classification of every ADR that
grep -ril "keycloak\|issuer\|client_credentials\|exchange"finds in the ADR directory, as amended (a decision changes; banner now, amendment with the stage), mentioned (context only; listed) or unaffected.
It takes effect at the I3 cut-over. Until then, ADR-048 describes the running system (the ADR-041 precedent).
ADR-050: Kanidm as the default upstream (U4)
-
E1. Default. Kanidm is the default for the devstack, the reference deployment and greenfield jurisdictions. ZITADEL and Keycloak are first-class alternatives (I4). A jurisdiction whose sources Kanidm cannot broker (Georgia: Okta SAML and eDirectory) picks ZITADEL, Keycloak or Okta OIDC as its one upstream. That is configuration, not code.
-
E2. Profiles are deployment configuration.
[identity]andleave the ruleset’sidp.toml. The profiles are kanidm, zitadel, keycloak and oidc-generic. A vendor profile ships only with a passing conformance suite (ADR-048 §3 restated). Upstream clients take extra trust anchors from configuration. -
E3. Operating model. Quarterly releases, upgrades from N-1 only, and 2-node replication. Logout is refresh revocation plus
prompt=login, with the AC-8 banner in canopy-web. Kanidm is built from source onrust:alpine; failing that, the image is pinned by digest and the Alpine exception is recorded here. -
E4. Verified facts. Dated and tagged, taken from U3’s JUnit results; build times and image size come from the command’s final step.
-
A per-client issuer, signing ES256.
-
Claim maps appear in the id_token and userinfo, never the access token, and are re-issued from current membership on refresh.
-
subis the entry UUID. There is noacroramr. Persons require MFA. -
Presenting a refresh token after a rotation that happened in a later second revokes the whole session. A rotation within the token’s own issuance second is not detected (the comparison is in whole seconds). So single-flight must hold across replicas, and a lost refresh response forces re-login.
-
An expired account cannot refresh.
-
No end-session endpoint. Client authentication is basic or post only. Access tokens live 900 s.
-
Tolerated deviation, read from source: authorization codes may be reusable within their 60 s lifetime. PKCE and the confidential client mitigate this.
-
-
E5. New-dependency comparison. Kanidm against ZITADEL, Keycloak and authentik on licence (each
LICENSEat the pinned tag), maintenance, adoption, security, musl/Alpine fit and footprint.
The Kanidm profile and suite (U2, U3)
-
Image (
devstack/kanidm/Dockerfile).-
Builder:
rust:1.96-alpineplusbuild-base cmake. It builds the v1.11.2 tarball (SHA-256 verified) withcargo build --locked --release -p daemonandKANIDM_BUILD_PROFILE=container_generic. It links no OpenSSL;deny.tomlcovers canopy’s own workspace only. -
Runtime:
alpine:3.23, non-root, withserver/core/staticat/hpkg. The command iskanidmd server.HEALTHCHECKrunskanidmd scripting healthcheck. -
There is no
entrypoint.sh.
-
-
Compose. Service
kanidmin profileidp-kanidm, which is outside every default profile and CI.-
Port 8443.
-
server.toml(version = "2",migration_path= the migrations directory under /etc/kanidm) and that directory are bound read-only. -
The DB is a tmpfs at /data, so every run starts fresh. The named volume
kanidm-tlsis at /tls. -
Environment:
KANIDM_DOMAIN=idm.canopy.testandKANIDM_ORIGIN=https://idm.canopy.test:<port>, since Kanidm overlaysKANIDM_*variables. -
KANIDM_CONFIG, set to the mounted server.toml under /etc/kanidm. Every kanidmd subcommand reads it (Kanidm’s server/daemon/src/opt.rs, line 117 at the tag), socert-generate,scripting healthcheckandscripting recover-accountsee the mounted configuration. Without it, the container profile would default to /data/server.toml.
-
-
xtask.
-
The port comes from
PORT_MAPPINGS(xtask/src/docker.rs), anddiscover_all_portsskips opt-in profiles. -
One helper in
xtask/src/devstack_guard.rscomputes the infra hash for both sites and excludesdevstack/kanidm/.
-
-
Migration (
devstack/kanidm/migrations/00-canopy.hjson).-
Persons
jane.doe,jane.snap-workerandjane.unscoped. Roles andprimary_programsmirrordevstack/keycloak/canopy-realm.json. Each UUID is the realm id with its fourth group set to0001, because Kanidm reserves everything below00000000-0000-0000-0001-000000000000. -
Groups
canopy_role_<role>andcanopy_program_<program>. -
A basic client
canopy-web:-
claim maps
rolesandprimary_programs(array join); -
scope map
openid profile; -
oauth2_consent_prompt_enable: false; -
short usernames;
-
an https redirect that is never followed;
-
PKCE enforced.
-
-
A name Kanidm refuses gets
_in place of., noted in the file.
-
-
Command (
cargo xtask identity conformance --idp kanidm [--keep]).-
Build with
--build. -
Clear the previous run:
rm --stop --force kanidm(after a failed run or--keep), then removekanidm-tls. -
Run
run --rm kanidm kanidmd cert-generate. It produces a 5-day leaf whose only SAN is the origin host. -
up -d, and wait until healthy. -
Copy the public CA out (
cp kanidm:/tls/ca.pemto .devstack/idp/kanidm-ca.pem) before any host-side HTTPS request. -
exec kanidm kanidmd scripting recover-account idm_admin, which prints JSON. -
Provision through
canopy_test_lib::upstream::kanidm::admin(theupstreammodule is not feature-gated):-
verify each migrated entry over REST, since a failed migration is only logged;
-
set a random 32-character password, then enrol TOTP through the credential-update session and read back the SHA-256 secret;
-
read
GET /v1/oauth2/canopy-web/_basic_secret.
-
-
Write the credentials file (.devstack/idp/kanidm.json, mode 0600) as
upstream::kanidm::Credentials:-
fields: origin, CA path, port, client id and secret, the idm_admin password, and each person’s name, UUID, password and TOTP secret;
-
secrets are
secrecy::SecretString, and nothing is printed.
-
-
Run
cargo clippy -p canopy-test-lib --all-targets --features idp-conformance -- -D warnings. Then runcargo nextest run -p canopy-test-lib --features idp-conformance --profile idp-conformance --test idp_conformance_kanidmwithCANOPY_IDP_CONFORMANCE__CREDENTIALSset. The JUnit then holds only this suite. -
Stop unless
--keepis given (step 2 of the next run removes the container either way). Print the cold and warm build times and the image size.
-
-
Driver (
crates/canopy-test-lib/src/upstream/kanidm/login.rs, JSON only).-
POST /v1/auth, echoingX-KANIDM-AUTH-SESSION-ID, throughinit,begin passwordmfa, TOTP, then password, which yields the UAT. -
GET /oauth2/authoriseas bearer. Discovery names the HTML/ui/oauth2; the code comments why the driver doesn’t use it. -
/oauth2/tokenwith basic auth. -
The HTTP client is built from
reqwest::Client::builder(): timeouts, the file’s CA,resolve("idm.canopy.test", 127.0.0.1:<port>), no redirects. -
The id_token is verified with jsonwebtoken via
canopy_auth::jwks::bind_algorithmagainst the per-client JWKS. Claims are judged by aClaimContractwith algorithms[ES256]and array pointers/rolesand/primary_programs.
-
-
TOTP.
totp-lite2.0.1 (SHA-256; MIT; 1.8 M downloads; small and finished, last released 2023-10). It fits the workspace’shmac0.12 andsha20.10.-
totp-rs 6.0.0 (2026-08, 10.7 M downloads) would duplicate
hmac,sha2andsha1. -
A hand-rolled RFC 6238 would be custom crypto.
-
-
Suite (
crates/canopy-test-lib/tests/idp_conformance_kanidm.rs,required-features = ["idp-conformance"]).-
The lane partition lists only
TEST_FEATURES, so the battery never runs it. validate’s clippy stage lints it through a newlanes::CLIPPY_FEATURES(TEST_FEATURESpluscanopy-test-lib/idp-conformance). -
The
idp-conformanceprofile serializes the suite with profile-leveltest-threads = 1. It uses no override group: test-lanes-lint lists every group filter underTEST_FEATURESonly (xtask/src/cmd/test_lanes_lint.rs), so it would reject a group for this gated binary. -
The profile also carries the eligibility clock pinner override, which
eligibility_clock_pin_runs_alone_in_every_profile(xtask/src/lanes.rs) requires in every profile. -
CI’s clippy job (
.gitlab-ci.yml, which quotes the features by hand) also addscanopy-test-lib/idp-conformance. -
A missing credentials file fails the test with an error; the test never returns early.
-
jane.doe:
-
discovery_names_a_per_client_es256_issuer_without_end_session(basic and post only); -
sign_in_with_pkce_and_totp_yields_a_verified_id_token(iss,aud,azp,nonceandauth_timepresent;subis the UUID; no consent; noacroramr); -
id_token_claims_project_through_an_oidc_generic_contract(the three roles union); -
prompt_login_refuses_a_session_that_is_not_fresh; -
max_age_refuses_a_stale_uat_and_a_fresh_sign_in_updates_auth_time(withmax_age=2, a UAT older than 3 s is refused; then a fresh sign-in yields a code whose id_token hasauth_timeno earlier than that sign-in); -
the_access_token_lives_900_seconds_and_carries_no_claim_maps; -
persons_are_offered_only_password_with_totp.
-
-
jane.snap-worker:
-
refresh_reissues_claims_from_current_membership_and_userinfo_matches:-
adds
canopy_program_tanf; -
the refreshed id_token has the same
iss,aud,sub,auth_timeandnonce, with a neweriat; -
userinfo’s
subequals the id_token’s;
-
-
replaying_a_rotated_refresh_token_revokes_the_session:-
sleeps 1.1 s between obtaining the token and rotating it, because Kanidm compares the token’s issuance second with the latest rotation’s;
-
the same-second exception is recorded in E4 and not tested, because that test would depend on timing;
-
-
a_revoked_refresh_token_cannot_refresh.
-
-
jane.unscoped:
an_expired_account_cannot_refresh(setsaccount_expirein the past). -
Unit tests: the compose arguments; the credentials file (round trip and 0600); proptests that the recover-account and compact-JWT splitters never panic.
-
-
Decision rules (applied in U4).
-
Claims are absent from the id_token but present in userinfo: the kanidm profile names userinfo.
-
Refresh omits the id_token: the kanidm profile renews through userinfo (D6).
-
STOP if any of these holds; ADR-050 is not accepted, and the result goes to the maintainer:
-
there is no claim path at all;
-
prompt=loginis ignored (logout relies on it); -
max_ageis ignored (step-up relies on it); -
an expired account can still refresh.
-
-
The Alpine build fails: pin by digest and record the exception.
-
Any other difference: correct E4, along with that test’s assertion and name, and explain it in the commit message. If it changes an ADR-049 row, STOP and report.
-
GitLab filing (at approval)
-
Epic &130 (program::infrastructure). Its body links this page, ADR-049 and ADR-050, the stage epics and U1-U4.
-
Stage epics (children of &130):
-
I1 (&131) "canopy-identity core: keys, client authentication, system tokens": D2, D3’s system token, D4’s purposes, D9, D10, D13. Absorbs #2343.
-
I2 (&132) "canopy-identity user plane: federation, sessions, delegation, revocation, device flow": D3’s session and delegation token, D4’s call graph, D5-D8, D12, E2. Absorbs #1447 and #1448.
-
I3 (&133) "Cut-over: every service on canopy-identity, Kanidm the default upstream": receivers, senders, canopy-web and its approval pages, the portal, canopy-cli, operator tools, k6, CI, a prebuilt Kanidm image, and the deletions. Absorbs #2344, #2345, #1595, #1869 and #1901.
-
I4 (&134) "Alternative upstreams: Keycloak and ZITADEL profiles and conformance lanes". Absorbs #2347 and #2349, and #2342 re-scoped to "a second upstream at the edge".
-
-
Closed as MR-1 merges: #2335 (obsolete); #2351 and #513 (won’t do).
-
U1-U4: priority::high, program::infrastructure, milestone "T5 — New Features".
-
U1 and U4: type::documentation, service::security.
-
U2: type::feature, service::devstack.
-
U3: type::feature, service::shared-crates.
-
-
The loader issue (#2489), "fix(signing,portal): key and secret loaders fail open outside development". type::security, priority::high, service::shared-crates, milestone "T1 — Correctness". It covers:
-
the .keys/ directory fallback and
MissingKey::Noop(crates/canopy-signing/src/program_signer.rs); -
file and environment fallbacks (
crates/canopy-signing/src/applicant_claim.rs); -
std::env::varreads, including the client secret’s literal dev fallback (services/canopy-portal/src/main.rs); -
the .keys/ directory fallback (
services/canopy-notices/src/main.rs).
-
Units — U1 → (U2 → U3 → U4)
U1 (w3) — docs: accept ADR-049, the identity plane split (#2485)
Files:
-
docs/modules/ROOT/pages/adrs/adr-049-identity-plane-split.adoc; -
[NOTE]banners on the ADRs classed amended; -
nav.adoc(the ADR row and this plan’s group); -
architecture.adoc(the index row); -
glossary.adoc(canopy-identity: ADR-019’s contract name, now canopy’s issuer); -
idp-integration.adoc(a NOTE); -
nist-architecture-mapping.adoc(PL-8); -
CHANGELOG.adoc(Changed); -
this page.
ADR-049 is Accepted (date) with a Ruling: line, and uses ADR-048’s sections plus Threat model and Alternatives. The banner reads: "Superseded in part by ADR-049, effective at the I3 cut-over: <one sentence>. Until then this ADR describes the running system." ADR-048’s Status gains "amended by ADR-049 (date)".
Acceptance: ADR-049 states D1-D14, the extras and the filing map, and every amended ADR carries its banner.
U2 (w5) — feat(devstack): add the opt-in Kanidm upstream profile (#2486)
Files:
-
devstack/kanidm/{Dockerfile,server.toml,migrations/00-canopy.hjson}anddocker-compose.yml; -
xtask/src/{docker.rs,devstack_guard.rs,lanes.rs}; -
xtask/src/cmd/{dev.rs,validate.rs,identity.rs}(cleangains the profile; clippy usesCLIPPY_FEATURES) andxtask/src/cmd/identity/conformance.rs; -
rust-toolchain.toml(the fifth Dockerfile); -
crates/canopy-test-lib/src/upstream/{mod.rs,kanidm/mod.rs,kanidm/admin.rs}; -
local-dev.adoc,tooling/xtask-catalog.adocandCHANGELOG.adoc(Added).
Acceptance: steps 1-8 succeed on a clean machine and again after a --keep run, the unit tests pass, and no secret is printed.
U3 (w5) — test(identity): add the Kanidm upstream conformance suite (#2487)
Files:
-
crates/canopy-test-lib/src/upstream/kanidm/login.rs; -
crates/canopy-test-lib/tests/idp_conformance_kanidm.rs; -
crates/canopy-test-lib/Cargo.toml(the feature, theentry andtotp-lite), plus the workspaceCargo.toml; -
.config/nextest.toml(profileidp-conformance, JUnit written to test-results/integration/idp-conformance.xml); -
.gitlab-ci.yml(the clippy job’s features).
Acceptance: all eleven tests pass on two fresh runs, and cargo xtask test-lanes-lint --static passes.
U4 (w2) — docs: accept ADR-050, Kanidm as the default upstream (#2488)
Files:
-
docs/modules/ROOT/pages/adrs/adr-050-kanidm-default-upstream.adoc; -
nav.adoc,architecture.adoc,nist-architecture-mapping.adoc(PL-8) andCHANGELOG.adoc; -
this page.
Acceptance: E1-E5 are recorded with the evidence, and the decision rules are applied.
Verification
-
MR-1.
cargo xtask plan-lint, thengit push(the pre-push battery). -
MR-2.
-
Open it as
Draft:so its!Nexists. -
Run
cargo xtask identity conformance --idp kanidmtwice, and read the JUnit file in full. -
Make the completion commit:
-
set
Done (YYYY-MM-DD) — !N; -
git mvthis page todocs/modules/ROOT/pages/plans/archive/identity-plane-split-i0.adocand repoint the nav; -
run
cargo xtask plan-lint --donewith--allow-openfor U2-U4 and every issue mapped to a stage epic above, naming them in the commit message.
-
-
git push, then take the MR out of draft.
-
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 (2026-09-30) |
Anthropic |
claude-opus-5-5 |
no-ship. Five blockers fixed: the completion sequence, the GitLab filing map, test isolation, clippy for the gated suite, and D9’s retire window. |
2 (2026-09-30) |
OpenAI |
gpt-6-astra |
no-ship. 15 findings and two corrections, all fixed:
No round 3. |