v16 spike: IdP-driven team/org membership via dynamic OIDC group mappings #77
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
priority
high
priority
low
priority
medium
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#77
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "%!s()"
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?
Tier 2 v16 follow-up: spike. Deferred until tenant orgs exist. Gated on #73 (landed, prod on Forgejo 16).
Forgejo v16 ships dynamic OIDC group mappings (upstream PR forgejo#11656, docs). Placeholder patterns on the auth source map IdP group claims to Forgejo org and team membership at login.
This is net-new membership sync. The reconciler does no team or org membership today. The mapping cannot set quota groups,
allow_create_organization, thehas_actionsunit or Renovate collaborators, so it complements the reconciler and replaces nothing (ADR 0017).How it works in v16
The auth source reads one group claim (
--group-claim-name) from the ID token or userinfo at login. The group names in that claim are matched against the configured mappings. Config lives on the Forgejo auth source (forgejo admin auth add-oauth/update-oauth, or Site Admin, Authentication Sources).--group-claim-name--group-team-map{org: [teams]}.--group-team-map-removal--dyn-group-maps["group-{org}-{team}"].--dyn-group-maps-removal--admin-group--restricted-groupDynamic patterns take
{org}and{team}from the group name. A claimed groupgroup-acme-developerswith patterngroup-{org}-{team}adds the user to orgacme, teamdevelopers. New orgs need no config change.Limits:
Risk: the removal toggles
With a removal toggle on, the mapping is authoritative over team membership. It strips any team a user was added to by hand. Keep removal off at first and treat the mapping as additive. Enable it per org only once trusted.
Keycloak specifics
groupsclaim. The mapper inopentofu/keycloak/clients.tofu(keycloak_openid_group_membership_protocol_mapper.groups) setsclaim_name = "groups"andfull_path = false, so the claim holds bare group names.forgejo_oidc_group_claimisgroupsand the admin value isforgejo_adminswhen Kanidm is off (ansible/roles/forgejo/defaults/main.yml).forgejo_roleclaim-map prerequisite is gone. Team groups are plain Keycloak groups, added inopentofu/keycloak/groups.tofu.tier_*andforgejo_*, so the reconciler's group handling stays unambiguous. Mind the lowercasing.roles/forgejo/tasks/oidc-source.ymlnow updates a drifted source throughupdate-oauth. Add the new flags there.Phased plan
groups.{org}and{team}, for examplefjteam-{org}-{team}.bitborgorgownersormaintainersteam. Removal off, additive only.fjteam-{org}-{team}groups to tenant org teams.roles/forgejo/tasks/oidc-source.yml.Recommendation: conditional go, but not now. With a handful of users and one first-party org there is little team management to automate. Adopt it when the multi-tenant team product ships.
Spike written up internally (not committed). Headline: conditional GO, but not now — defer until the tenant-org/team product exists.
What it does (v16, PR 11656 + docs): the OIDC auth source reads one group claim (
--group-claim-name) at login and syncs org-team membership. Static map (--group-team-map), dynamic placeholders{org}/{team}(--dyn-group-maps), plus removal toggles (--group-team-map-removal/--dyn-group-maps-removal) and admin/restricted group values. Login-time only (no timer); adds to existing orgs/teams only (won't create); names lowercased.Fit: net-new — the reconciler does no team membership today, so this replaces nothing and complements it (reconciler keeps quota/org-create/
has_actions/Renovate; ADR 0016/0017 — none are claim-mappable). Real value is future tenant-org teams; near-zero today (~a handful of users, one first-party org).Interactions: login-time ⇒ membership lags to next login vs the reconciler's ~15-min timer; removal toggle is the "dangerous half" (can strip hand-curated teams) — keep off, additive only. Orthogonal to #80 (JWT).
Prerequisite (do first): our single group claim is already spoken-for —
--group-claim-name=forgejo_rolewith--admin-group=admin; scopes includegroups. Cleanest path: extend the Kanidmforgejo_roleclaim-map to also emit team tokens (keep admin intact) rather than repoint to rawgroups. Verify Kanidm scope/claim-map on the live client before adopting. Also:oidc-source.ymlis add-only — enabling on the existing source needsauth update-oauth(runbook).Retarget: Kanidm is being replaced by Keycloak before launch (bitborg/bitborg-docs#127). After cutover this reads Keycloak groups, roles and user attributes instead of Kanidm.
Forgejo v17 note. The group-team map flags (
--group-team-map,--group-team-map-removal,--dyn-group-maps,--dyn-group-maps-removal) are unchanged from 16.0.6, so this can be prepared now.v17 changes:
{org}and one{team}, or it is skipped with an error log. The rest of the pattern is regex-quoted.update-oauthneeds a Forgejo restart.Prep: add the flags to both argv lists and the drift compare in
oidc-source.yml, behind a variable that stays empty. The Keycloak groups mapper must emit bare names: a leading/does not match the placeholders.Forgejo v17.0.0 (live since 2026-10-17) hardens dynamic OIDC group mappings (PR13056). It escapes regex characters, skips patterns with a wrong placeholder count and never removes the last owner of a team. That removes the worst failure mode of the removal toggles. Spike on v17.