fix(kanidm): declare the portal OAuth2 clients and drop the localhost origin from production #278
Inga granskare
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-infra!278
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "fix/275-oauth2-client-declarations"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
Part of #275, and the more urgent half. Two live misconfigurations, fixed declaratively.
1. The production client accepted a localhost redirect
oauth2_strict_redirect_urionly requires the redirect to match some registered origin, andlocalhost was registered — so it offered no protection here. Combined with a scope map covering
forgejo_users(every person on the service), an authorization code intended for the portal could beredirected to a listener on a user's own machine.
Declaring only the real callback removes the localhost entry:
originUrlreplaces the attributerather than appending, verified in upstream
main.rs.2. The dev client was visible to every user
bitborg-web-devwas also scope-mapped toforgejo_users, and Kanidm lists an application on thelanding page of anyone in a scope-mapped group — which is exactly the reported symptom
("bitborg portal (dev)" showing to non-admins).
Remapped to
forgejo_admins. Verified against the live server with the read-only reconciler tokenthat the group resolves to
['supernaut@auth.gitborg.se'], so local development keeps working andnobody else sees the client.
Kept rather than deleted, deliberately. Deleting it would push local OIDC testing back onto the
production client — which is plausibly how the localhost origin got there in the first place. Fixing
the visibility while keeping a legitimate dev path is the durable outcome.
What is NOT declared, and why
forgejoandgrafanaare omitted. The forgejo client carries sevenoauth2_rs_claim_mapentries driving entitlement claims (
ent_lfs,ent_runners_*) and theforgejo_roleadmin claim.Declaring a client replaces its attributes, and
removeOrphanedClaimMapsdefaults true, so apartial declaration would strip those claim maps and break entitlement mapping and admin assignment.
--no-auto-removemeans an undeclared client is left untouched rather than deleted, so omitting themis safe. Bringing them under declaration needs their claim maps reproduced exactly — its own change,
with its own dry-run.
Checks made before touching anything near SSO
basicSecretFileis never emitted, and kanidm-provision only rewritesthe secret when that field is present: Absent field, block skipped, existing secret untouched.
except the two being changed.
preferShortUsernameistrueforbitborg-webandfalsefor thedev client, both matching current live values.
oauth2_strict_redirect_uri) are not managed and stay as-is.Hardening: the state file is now validated
Added
validate: "python3 -m json.tool %s"to the template task. The template hand-assembles JSONfrom Jinja loops, so an unbalanced brace is a realistic edit mistake — and it would replace a working
state file and surface as a confusing kanidm-provision parse error. Neither
validatenor theprovisioning command runs under
--check, so a dry-run could never catch it.Verification
--syntax-checkpasses;ansible-lint roles/kanidm/passes on the production profile.--check --diff --tags kanidmagainst prod renders the newsystems.oauth2block with balancedbraces, and the account-policy gate from #277 still reports
matches the declared credential_type_minimum 'mfa'.ok=24 failed=0.command, so it skips under--check.The rendered state file is verified; the mutations it will drive are not. Worth watching the apply
output for
Updatinglines againstbitborg-webandbitborg-web-devand nothing else.Post-apply checks
kanidm system oauth2 get bitborg-web— one origin only.kanidm system oauth2 get bitborg-web-dev— scope map onforgejo_admins.pnpm devOIDC login still works.