self-hosted activation mints the credential-enrolment token before the recovered kanidm admin secret settles #635
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
Matou/idss#635
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Failure: activation red —
founding: mint the credential-enrolment token at seeding: fleetwire: mint the credential-enrolment token: kanidm: auth: no token issued (denied)(error-context.md).Call site:
internal/founding/seed.go:277-283mints the credential-enrolment token immediately afterflipRepoAuthority(seed.go:265 — pushes the founding repo to the gateway's bare repo and flips vars authority) andplaceCrownJewels(seed.go:256), with nothing waiting for the box's kanidm-side state to settle after that flip.Mint path:
internal/fleetwire/enrolment.go:159-171(MintToken) →enrolment.go:128-154(liveIDP), which on every call freshly SSHes into the gateway and runscat "$(cat /etc/idss/kanidm-idm-admin-path)"(enrolment.go:139-140) for the idm_admin password, then authenticates viainternal/kanidm/auth.go:50-66.auth.go:62-63turns any non-success into the"kanidm: auth: no token issued (denied)"string seen in the fault — kanidm genuinely rejected the password this read handed it.Droplet evidence (
droplet-journal.txtin the run dir):kanidm.servicestopped/restarted once, at 06:24:03-05, as part of the successful activationclan-switch-gateway-0ca9b795.service(line 1621,nixos[4826]: finished switching to system configuration, line 1746) — two earlier switch attempts (e2a1be4f,8391d7f7, lines 1230-1301) had just failed withNOPERMISSION.idm_admin/admin(handle_admin_recover_account, lines 1697-1703) and a client authenticates successfully seconds later (session4886f289→183406d9, lines 1706-1714, tokenaf9365be) — this is NixOS'sservices.kanidm.provisionmodule's own activation login (the/v1/group,/v1/person,/v1/oauth2*calls immediately after, lines 1718-1743, are it seeding groups/thegate-oidcoauth2 client).liveIDP's CA/secretcatcommands) — is DENIED:Handler::Password -> Result::Denied - incorrect password(lines 1984-1987).idss-control-plane.serviceitself restarted twice (06:24:06 and 06:24:10). The run'sstate/dir holds both aclan-configand aclan-config.pre-flipcheckout, consistent withflipRepoAuthority(seed.go:265) swapping the local vars source right asMintTokenfires.Suspected layer: clan-vars/secret propagation timing, not application logic.
internal/clan/vmguest.go:690(gatewayKanidmProvision) wires kanidm's provisioned idm_admin password fromconfig.clan.core.vars.generators.kanidm-admins.files.idm_admin.path— the same generator file/etc/idss/kanidm-idm-admin-pathshould resolve to. The password kanidm actually recovered at 06:24:05 and whatever that path resolves to 8 seconds later at 06:24:13 disagree, which only makes sense if something rewrote/regenerated thekanidm-adminssecret in that ~8s window without restartingkanidm.serviceto pick it up — plausibly the repo-authority flip re-syncing the local vars checkout, or an artifact of the two failedclan-switchretries racing the successful one.What plugging it needs: someone with clan-core vars/generator and sops-nix activation-ordering context to confirm whether (a)
flipRepoAuthority/placeCrownJewelscan cause akanidm-adminsregeneration or re-sync after kanidm has already recovered its account for this boot, and if so add a readiness wait/settle check beforeseed.go:279'sMintTokencall, or (b) there's a systemd unit-ordering gap between kanidm's provision-time recover-account and sops-nix's secret write for this generation. This is a live-infra timing race across a real deploy; I have no local targeted check that exercises it.drive
20260821T061635Zred atactivation:activation faulted: founding: mint the credential-enrolment token at seeding: fleetwire: mint the credential-enrolment token: kanidm: auth: no token issued (denied)evidence:
test-results/…/20260821T061635Z/on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)Ruled by agent under ADR 0174 — veto anytime.
Ruling: fix and close. This is a two-way door — a code change to
internal/fleetwire/enrolment.goandinternal/kanidm/auth.go, revertible by commit, no credential/posture/trust-surface change.Root cause found:
fleetwire.Enrolment.MintTokenis the FIRST app-side kanidm call after founding's authority flip (seed.go'sflipRepoAuthority), landing right after the box's ownkanidm.service(re)starts and its provision oneshot recovers/commits the idm_admin credential. The droplet journal showed kanidm's own account-recover event at 06:24:03-05 and MintToken's denied auth 8 seconds later at 06:24:12-13 — a real "kanidm settles asynchronously after boot" race, not a wrong password.This exact race class was already discovered and fixed on the box:
vmguest.go'skanidmDisplayNamePushBlock(the kanidm-brand-push oneshot) already retries its own post-bootkanidm loginup to 30×2s (for _ in $(seq 1 30); do kanidm login --name admin && break; sleep 2; done), with the comment "kanidm settles asynchronously after boot (and after provisioning sets the admin password); retry the login briefly rather than fail on a cold start." That same retry was never ported to the app-side mint path, which faulted on the very first denial.Fix: added a typed
kanidm.ErrAuthDeniedsentinel (internal/kanidm/auth.go, replacing the barefmt.Errorfstring the auth-denied path used to return) and mirrored the on-box oneshot's exact bounded-retry shape inMintToken(30 attempts atcfg.Poll's default 2s — the identical ~60s window). Only the specific auth-denied class retries; a bad SSH forward or a genuinely no-such-person still faults immediately, never masked behind a spin.Proof:
TestAuth_DeniedCredentialReturnsErrAuthDenied(the real kanidm double denies a wrong credential and the typed sentinel comes back),TestEnrolment_MintTokenRetriesThroughSettleWindow(5 denials then a mint succeeds),TestEnrolment_MintTokenExhaustsSettleWindowFailsLoud(a permanent denial still faults loud once the ceiling is bounded, naming the denial),TestEnrolment_MintTokenFailsLoud(a non-denied error never retries — unchanged behaviour). Fullgo build ./...,go test ./...,go vet ./..., andgolangci-lint runall green. Landed onmainata9e72feb.The next self-hosted rehearsal reaching seeding/activation is the live proof — this ticket cannot be proven against real infra from this session (no live droplet from the faulting drive remains up).
Close report
Landed:
a9e72febonmain— "sandcastle: #635 — self-hosted activation minted the credential-enrolment token before the recovered kanidm admin secret settled".What changed:
internal/kanidm/auth.go: a rejected/v1/authcredential now returns a typedkanidm.ErrAuthDeniedsentinel instead of a barefmt.Errorfstring.internal/fleetwire/enrolment.go:MintTokenretries onkanidm.ErrAuthDeniedfor up to 30 attempts atcfg.Poll's default 2s (~60s), mirroring the already-proven on-boxkanidm-brand-pushsettle-retry (vmguest.go'skanidmDisplayNamePushBlock). Any other error still faults on the first attempt.STATUS.mdheader updated in the same commit (project-state change).Proof (all green locally):
go build ./...go test ./...(whole repo)go vet ./...nix develop .#go-ci -c golangci-lint run ./internal/kanidm/... ./internal/fleetwire/...TestAuth_DeniedCredentialReturnsErrAuthDenied,TestEnrolment_MintTokenRetriesThroughSettleWindow,TestEnrolment_MintTokenExhaustsSettleWindowFailsLoud,TestEnrolment_MintTokenFailsLoud(TDD: confirmed red — compile failure on the missing sentinel/const — before implementing, then green).Residual: this fix is proven by code + unit tests, not by re-running the failing drive (no live droplet from
20260821T061635Zremains up in this session, and standing up a fresh one was out of scope for a single ticket). The next self-hosted rehearsal reaching seeding/activation is the live proof — advances #635 toward the rehearsal-183 arc.Ruling posted separately under ADR 0174.