oidc-admin red (sig 94a048d819e4): gate-oidc's enforced PKCE never satisfied by control-plane's OIDC client — files.<apex> re-gate (#566) breaks under it #643
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
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
Matou/idss#643
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
Drive
20260822T010329Z, legoidc-admin, red onpage.waitForSelector('#header')timeout (60s), raced against a kanidm-login-field wait that also timed out (app/tests/e2e/fixtures/provision.ts:640-647) — neither Nextcloud's signed-in chrome nor kanidm's login form ever appeared afterceremony.goto(doorPath(door, '/login'))(app/tests/e2e/journey.droplet.spec.ts:576-579).Root cause
kanidm's
gate-oidcOAuth2 client — the community-SSO gate's own OIDC client (ADR 0074/#566), provisioned ininternal/clan/vmguest.go:679-687(gatewayKanidmProvision'sgateOAuth2block) — is never givenallowInsecureClientDisablePkce = true, so the NixOS kanidm module enforces PKCE on it by default (nixos/modules/services/security/kanidm.nix:652-654,918-919, confirmed present in this repo's nix-store checkout). But the control-plane's own OIDC client,internal/controlapi/oidcprovider.go:71-88(kanidmOIDC.AuthCodeURL), builds the authorize URL with onlyresponse_type,client_id,redirect_uri,scope,state— nocode_challenge/code_challenge_method.Evidence, live on this run —
logs/droplet-journal.txt:1983-1992(timestamps 01:16:53–54Z, inside the oidc-admin leg's window perartifacts/legs.json):(repeats twice, ~1s apart — two independent forward_auth 401 round-trips).
Why this leg, not the earlier ones
On the own-VPS public path every SERVICE route (files included) sits behind the gate's
forward_authtemplate again since #566 (internal/clan/frontdoor.go:405-439renderRoute, comment at 405-411)./loginis not infiles.go'sFilesExemptPaths(internal/clan/files.go:74-79, only DAV +/status.phpare exempt) — files.go:63-64 says as much: "direct browser entry to files. stays behind forward_auth". So any browser hittingfiles.<apex>/loginwithout a community SSO cookie 401s, gets redirected to/authz/signin?rd=...(internal/controlapi/signin.go:124-144), which 302s to kanidm'sgate-oidcauthorize endpoint — and dies on the PKCE check above.The bare apex root (
portalAddress, whatsign-in/co-host/deploy-files/files-healthy/doorall exercise) is explicitly ungated (internal/clan/frontdoor.go:487-498renderPortalRoute, "Ungated this arc (#512, parity with the private path)") — those legs never touch the broken gate at all, which is why they stayed green.branded-login(the leg immediately before oidc-admin) also hitsfiles.<apex>/login, from a fresh cookie-less browser, and also PASSED (866ms) — almost certainly a false green: its assertion (provision.tsassertBrandedLogin, waits onh3, input[type=text]:visible, input[name*="user" i]:visible) is loose enough that kanidm's own community-branded "Unable to authorise" error shell likely satisfies it, since kanidm renders the community heading on its error pages too.oidc-admin's stricter race (real Nextcloud chrome vs. a real username field) is what actually caught the break.Suspected layer
Go (
internal/controlapiOIDC client) + Nix render (internal/clan/vmguest.gokanidm client provision) — security-sensitive auth-flow code, not a rendering/selector/constant slip.What plugging it needs
A ruling on approach, then implementation:
code_verifierper flow insigninStart, add it to the sealedflowState(internal/controlapi/signin.go:211-215), sendcode_challenge/code_challenge_method=S256inAuthCodeURL(oidcprovider.go), and the storedcode_verifierinExchange's token POST. Touches theOIDCProviderinterface (both methods' signatures) and its seam-test fakes (internal/controlapi/signin_test.go, likely anoidcprovider_test.go) — genuine feature work, not mechanical.allowInsecureClientDisablePkce = trueon thegate-oidcclient invmguest.go:679-687— a one-block Nix change, but a conscious security-posture call (the nixpkgs option name says as much: "You should request the client to enable PKCE!") that needs a human/ADR ruling, not a silent self-fix, and isn't verifiable against a real kanidm from this checkout anyway.Either way,
assertBrandedLogin's selector (provision.ts) is worth tightening afterward so this failure mode can't false-green again.Run dir:
/home/dev/swarm/Matou/idss/test-results/drive-droplet/20260822T010329Zdrive
20260822T010329Zred atoidc-admin:page.waitForSelector: Timeout 60000ms exceeded. Call log: - waiting for locator('#header') to be visibleevidence:
test-results/…/20260822T010329Z/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: implement PKCE properly (option 1), not the Nix
allowInsecureClientDisablePkceescape hatch (option 2).Why this is the two-way door: option 1 is a code change to
internal/controlapi/{signin,oidcprovider}.go, revertible with a commit, and provable by the existing OIDCProvider seam tests (signin_test.go) plus a new PKCE-specific assertion inTestKanidmOIDC_ExchangesAgainstAFakeIdPandTestAuthzSignin_CompletesFlowAndMintsSession— no live kanidm needed to prove the client now sends a matchingcode_challenge/code_verifierpair, per ADR 0174 rule 1.Option 2 is explicitly out of scope for this session: it is a security-posture widening (disabling PKCE enforcement on a real OAuth2 client) — ADR 0174 rule 3's one-way-door list names this exact class ("loosening an auth requirement, the #329-class ruling"). It also isn't verifiable from this checkout (no live kanidm). Not taking it.
Proceeding with option 1.
Close report
Landed:
acc5a7aa— control-plane's OIDC client now runs PKCE (RFC 7636 S256), matching kanidm's enforcedgate-oidcclient (option 1 from the ticket; ruling above).What changed:
internal/controlapi/signin.go:signinStartmints an S256code_verifier/code_challengepair per flow (newPKCE), seals the verifier in the existing signed, HttpOnly flow cookie (never the browser-visible authorize URL), andsigninCallbackhands it toExchangeat token-exchange time.flowStategained aCodeVerifierfield.internal/controlapi/oidcprovider.go:kanidmOIDC.AuthCodeURLnow sendscode_challenge/code_challenge_method=S256;Exchangenow sendscode_verifierin the token POST.OIDCProvider's two interface methods each gained a PKCE parameter (no other callers in the tree — grepped clean).internal/controlapi/signin_test.go(TDD, red confirmed first viago vetfailing on the old signatures): the full-flow seam test now asserts kanidm receives acode_challengeat authorize and that the exchange-time verifier's S256 hash matches it;TestKanidmOIDC_ExchangesAgainstAFakeIdPruns against a fake IdP that itself enforces PKCE (400s a mismatched/missing verifier, modelling kanidm's real behaviour), asserting both the successful pair and a mismatched-verifier failure.app/tests/e2e/fixtures/provision.ts'sassertBrandedLogin: dropped the bareh3alternative from its wait selector — kanidm renders the same community-branded heading on its own authorise-ERROR shell, so the old selector could false-green (this is very likely what happened tobranded-loginon the failing drive, per the ticket's own analysis). Now requires the actual username field.Nix side: confirmed
internal/clan/vmguest.go'sgateOAuth2block needed NO change — the fix is entirely the Go client now speaking PKCE. Did not touchallowInsecureClientDisablePkce(option 2) — that stays unruled, per the ADR 0174 comment above (one-way-door security-posture widening).Proof:
go build ./...,go vet ./...,gofmt -l .— clean.go test ./...— all green (internal/controlapi0.2s, full tree ~unchanged elsewhere).vue-tsc -p app/tsconfig.json(coversapp/tests) — clean, confirms theprovision.tsedit type-checks.oidc-adminleg against a real kanidm — this session's checkout has no live kanidm to exchange a real PKCE-enforced authorize/token round-trip against, same constraint the ticket itself named. Closing on the strength of the seam tests proving the client now sends and round-trips a genuine matching PKCE pair (ADR 0174 rule 1: revertible + provable by existing test), consistent with the #641/#642 precedent this same drive lineage set.advances #643