operator-document-archive: #1553's pre-provision never binds to the operator's OIDC identity — django-allauth signs them into a SECOND, unprivileged account while the panel reports superuser forever #1605
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.
Dependencies
No dependencies set.
Reference
Matou/idss#1605
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?
The failure
Drive
20260918T200406Z(commit5b1ca810) red atoperator-document-archive:The username in Paperless's own refusal —
proof-operator3, notproof-operator— is the whole fault.What the box said
The drive kept its droplet (
artifacts/live-box.json,kept_on_red). Read-only, off209.38.94.45:Read the timestamps against the leg order:
grant-operatorleg fires the reconciler;provisionOperatorPOSTs/api/users/and creates id 4proof-operator, superuser + staff, no email.operator, the same trap, un-sprung only because nobody signed into Paperless as them this drive.operator-document-archiveleg signs in through kanidm. django-allauth auto-signup creates a brand-new id 6proof-operator3, no admin flags, and binds the kanidmuidto that row. Id 4 is left orphaned.systemctl --failedlisted 0 units;paperless-weband thedocument-archive-oidconeshot are both healthy. Nothing crashed — the wiring is doing exactly what it was written to do.The defect
internal/documentarchivesvc/documentarchivesvc.go:227states the premise the box falsifies:Paperless-ngx does not use mozilla-django-oidc. It uses django-allauth —
internal/clan/paperless.go:358registersallauth.socialaccount.providers.openid_connect, and:359setsPAPERLESS_SOCIAL_AUTO_SIGNUP = "true". Allauth's auto-signup never adopts an existing local account by username; on collision it generates a free one by suffixing. That isproof-operator3exactly.The fault is permanent, not a race.
account()(documentarchivesvc.go:282) looks the person up withGET /api/users/?username=proof-operator, which still finds the orphaned id 4 already holding both flags, soReconcileRoletakes the idempotent no-op at:209on every subsequent pass, forever. The real, signed-in account is never seen. Consequentlyartifacts/roles/detail-proof-operator-after-redeploy.jsonreads{"service":"document-archive","has_access":true,"role_in_app":"superuser"}with nonot_appliedmarker — the panel tells the community the operator bit is applied while the box holds the operator at no privilege. A truthfulness fault on a posture card, not only a missing bit.member-document-archiveis green for the right reason: a plain member is a deliberate no-op (:203), so no pre-provisioned row exists to collide with andproof-member(id 7) auto-signs-up at its own exact username.Subsidiary finding, same territory
Group sync produced nothing at all:
paperless.go:360setsPAPERLESS_SOCIAL_ACCOUNT_SYNC_GROUPS = "true"and the oneshot maps thepgroupsclaimoperators -> admins/idm_all_persons -> members(paperless.go:598-599), but neither Django group exists on the box and no membership rows were written — Paperless's group sync assigns to groups that already exist, it does not create them. Worth fixing alongside, though it cannot substitute for the fix:/admin/gates on theis_staffBIT, which no Django group can confer.Why this needs a ruling (refusal rule 3)
I refused this rather than fast-laning it. The repair is not mechanical — it is a decision about how a ledger identity binds to an allauth account, and the candidates are materially different products:
SOCIALACCOUNT_EMAIL_AUTHENTICATION+SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT, and haveprovisionOperatorwrite the person's email plus a verifiedaccount_emailaddressrow. This makes an IdP-asserted email silently adopt a pre-existing local superuser account. That is a security posture at a trust moment and wants an ADR, not a healer's commit.uidrather than the username. Honest and narrow, but it reverses #1553's ruling — an operator granted before first sign-in lands non-admin until a reconcile pass catches them.is_staff/is_superuserfrompgroupsat each sign-in. Closest to "an operator is admin everywhere" and self-healing, but it is new product surface on the sign-in path.Whichever is ruled, the fix spans the Nix render (
internal/clan/paperless.go), the port (internal/documentarchivesvc/), and the double — and it cannot be proven on the workstation. The only test surface is the hand-written double atinternal/documentarchivesvc/documentarchivesvc_test.go:52-57, whosesignUpis username-keyed and whose comment (:90-91) encodes the very premise that produced this bug. Any double I wrote here would simply re-encode whichever linking semantics I assumed; its green would prove nothing. The proof is the next drive'soperator-document-archiveleg.Whoever takes this: make the double faithful FIRST — teach
signUpto suffix on username collision and to record the social binding, watchTestDocumentArchivePort_OperatorBeforeFirstSignInIsPreProvisionedgo red the way the box did, and only then build the ruled fix. That is the shape that worked for the Listmonk enum fault (#1592).Suspected layer
The document-archive port's identity-binding assumption (
internal/documentarchivesvc/documentarchivesvc.go:224-241), written against the wrong OIDC library's semantics, plus the allauth linking settings absent from the render (internal/clan/paperless.go:355-361).The drive's other four reds — already addressed, not filed here
operator-whakapapa,member-whakapapa,operator-newslettersandmember-newslettersall failed with kanidm's ownError Code: InvalidState. That is the PKCE refusal ruled on in #1601 and landed byc0c8d550(ADR 0254), which is newer than this drive's commit5b1ca810— the drive could not have carried the fix. Those four re-prove on the next fire and want no new ticket.Advances #1547.
drive
20260918T200406Zred atoperator-document-archive:document-archive: the granted operator did not reach the admin surface /admin/ — HTTP 200, landed "https://document-archive.roles-proof.idss.nz/admin/login/?next=/admin/", 0 match(es) for "#user-tooevidence:
/home/dev/swarm/Matou/idss/test-results/drive-rented-services/20260918T200406Zon matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was capturedState, from the #1547 babysitting session (Claude, Ben's laptop) — this needs Ben's ruling, and I acted before asking.
I reached the same diagnosis from the kept box (#1604) and landed candidate 1 on main as
d3e545c9before reading this ticket: the render sets the allauth provider app'semail_authentication: true(NOTAUTO_CONNECT— Paperless exposes no env for it; the match is re-made by email at each sign-in), andprovisionOperatorwrites the person's email. I judged it covered by ADR 0251 (Grist and Listmonk already know a person by the email kanidm asserts). This ticket is right that adopting a pre-existing superuser account on an IdP-asserted email is a trust decision of its own. It should have gone to Ben first. It is on main but deployed nowhere — only a throwaway proof box will ever boot it until the update lane is live — and it is one revert.What the switch trusts: whoever kanidm says holds verified email X is signed in to the Paperless account holding email X. In IDSS only operators write a person's email (kanidm's self-service mail write is not granted),
ErrEmailInUsekeeps one address to one member, andNormalizeEmailrefuses dot-less domains, so Paperless' built-inadmin(root@localhost) cannot be claimed. An operator is already superuser on Paperless, so the people who could abuse it already hold what it would give.Options for Ben: (1) keep it, recorded as an ADR; (2) revert, drop pre-provision, reconcile after first sign-in (reverses #1553: an operator granted before first sign-in is non-admin until a later reconcile); (3) revert, carry the admin bit in a claim through a Paperless adapter (new code on the sign-in path, a patched Paperless).
Relabelled
ready-for-human. Unlinked from #1547 so the proof drive can show the behaviour live on a throwaway box while the ruling is open; #1547 is not to be called done until this is ruled.Ruled by Ben, 2026-09-18, in session: option 1 — keep the verified-email match. Recorded as ADR 0255 (
d239b2ad), which also records that the change (d3e545c9) was landed before it was put to him. The double was made faithful as this ticket asked (it matches a sign-in by email, never username, and de-duplicates the username on a miss). Live proof is the next #1547 fire'soperator-document-archive. Closing.