feat(keycloak): switch staging from kanidm to keycloak #633

Sammanfogat
supernaut sammanfogade 2 incheckningar från feat/staging-keycloak-cutover in i main 2026-10-09 19:21:28 +00:00
Ägare

Refs #574, #575.

What

One switch, kanidm_enabled (default true). Staging sets it false, which rehearses the prod cutover:

  • Keycloak takes keycloak_domain (auth.stg.bitborg.se on staging). The kc.stg vhost is gone.
  • kanidm role: stops the unit and removes its Quadlet. Volume and config stay for rollback.
  • Caddy: the Kanidm vhost is gated.
  • Forgejo: oidc-source.yml compares the existing Bitborg Auth source (only a sha256 of the secret leaves Postgres) and runs update-oauth --id on drift, then restarts Forgejo. Same source id, so linked accounts stay linked. Discovery under /realms/bitborg/, group claim groups, admin group forgejo_admins.
  • Reconciler: writes KEYCLOAK_* (KEYCLOAK_URL=http://127.0.0.1:18080, host network). Staging pins v2.0.0. The role refuses a v1 image when Kanidm is off.
  • Health gate: Keycloak realm discovery replaces the Kanidm checks. The Kanidm concealment-tag check only runs while Kanidm is on.
  • Runbook: "Cutover switch" with apply order kanidm,keycloak,caddy,forgejo,reconciler and rollback.

Prod

No change while kanidm_enabled: true. --check --diff --limit bitborg-prod shows changed=0 for kanidm, keycloak, forgejo, caddy, reconciler, web and health-check. Remaining prod-flip items are listed on #575.

Staging

Applied and verified: new issuer on auth.stg, Forgejo and portal sign-in redirect to Keycloak, billing and portal reach the admin API, Kanidm inactive with volume kept, reconciler v2 timer succeeds, health gate passes. A second --check over all six tags shows changed=0. Tofu staging plan: no changes.

Still to test by hand: Forgejo sign-in with passkey and with password plus TOTP.

Refs #574, #575. ## What One switch, `kanidm_enabled` (default `true`). Staging sets it `false`, which rehearses the prod cutover: - Keycloak takes `keycloak_domain` (`auth.stg.bitborg.se` on staging). The `kc.stg` vhost is gone. - kanidm role: stops the unit and removes its Quadlet. Volume and config stay for rollback. - Caddy: the Kanidm vhost is gated. - Forgejo: `oidc-source.yml` compares the existing `Bitborg Auth` source (only a sha256 of the secret leaves Postgres) and runs `update-oauth --id` on drift, then restarts Forgejo. Same source id, so linked accounts stay linked. Discovery under `/realms/bitborg/`, group claim `groups`, admin group `forgejo_admins`. - Reconciler: writes `KEYCLOAK_*` (`KEYCLOAK_URL=http://127.0.0.1:18080`, host network). Staging pins `v2.0.0`. The role refuses a v1 image when Kanidm is off. - Health gate: Keycloak realm discovery replaces the Kanidm checks. The Kanidm concealment-tag check only runs while Kanidm is on. - Runbook: "Cutover switch" with apply order `kanidm,keycloak,caddy,forgejo,reconciler` and rollback. ## Prod No change while `kanidm_enabled: true`. `--check --diff --limit bitborg-prod` shows changed=0 for kanidm, keycloak, forgejo, caddy, reconciler, web and health-check. Remaining prod-flip items are listed on #575. ## Staging Applied and verified: new issuer on `auth.stg`, Forgejo and portal sign-in redirect to Keycloak, billing and portal reach the admin API, Kanidm inactive with volume kept, reconciler v2 timer succeeds, health gate passes. A second `--check` over all six tags shows changed=0. Tofu staging plan: no changes. Still to test by hand: Forgejo sign-in with passkey and with password plus TOTP.
supernaut lade till 2 incheckningar 2026-10-09 19:11:01 +00:00
Add kanidm_enabled (true by default, so prod renders unchanged). Staging sets
it false and moves keycloak_domain to auth.stg.bitborg.se.

With Kanidm disabled:
- the kanidm role stops the unit and removes its Quadlet file. The volume and
  config stay for rollback.
- Caddy drops the Kanidm vhost, so Keycloak takes the auth name.
- Forgejo's "Bitborg Auth" source points at the realm discovery URL with the
  groups claim and forgejo_admins. oidc-source.yml now updates an existing
  source in place, by id, when its settings or secret differ.
- the reconciler env carries KEYCLOAK_*. Staging pins reconciler v2.0.0.
- the health gate checks the realm discovery document instead of Kanidm.

Refs #574
fix(identity): order the cutover applies and guard the reconciler tag
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m51s
1b55daa274
Apply caddy before forgejo in the cutover and rollback order. Forgejo
fetches OIDC discovery at start and must not reach a stopped Kanidm.

Assert reconciler v2 or later when kanidm_enabled is false, since a v1
image cannot read the KEYCLOAK_* env. Skip the Kanidm concealment-tag
check when Kanidm is disabled.

Refs #574
supernaut sammanfogade incheckning 7e0815c0c1 till main 2026-10-09 19:21:28 +00:00
supernaut tog bort grenen feat/staging-keycloak-cutover 2026-10-09 19:21:28 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra!633
Ingen beskrivning angiven.