feat!: read identities and entitlements from keycloak #79

Sammanfogat
supernaut sammanfogade 2 incheckningar från feat/keycloak-client in i main 2026-10-08 20:23:27 +00:00
Ägare

The reconciler reads identities and entitlements from Keycloak's admin REST API instead of Kanidm (ADR 0044). Breaking: 2.0.0. Do not tag v2.0.0 until a dry run against the staging realm passes.

What

  • Client: src/keycloak-http.ts replaces the Kanidm client.
    • Gets a client-credentials token as bitborg-reconciler, cached and refreshed before expiry.
    • Reads users (with attributes), group members, and realm roles with their users and groups.
    • Every list is paged (first/max, 100 per page). Any failed page aborts the run.
    • A missing group or role aborts instead of reading as empty.
  • Expansion: a role's members are its direct users plus the members of each group the role is mapped onto. That is the ADR 0044 tier-group model.
  • Safety:
    • Reads stay fail-closed, and Keycloak is read before any Forgejo write.
    • The all-tiers-empty refusal stays.
    • The join key is unchanged: the Keycloak user id against Forgejo login_name.
  • Display name: from user attribute displayName, falling back to firstName lastName. An absent value stays absent, so the never-clear rule holds.

Configuration (breaking)

  • KEYCLOAK_URL, KEYCLOAK_REALM, KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET replace KANIDM_URL and KANIDM_TOKEN.
  • The KANIDM_GROUP_* variables split by kind:
    • tier groups: KEYCLOAK_GROUP_TIER_BASIC, _TIER_PRO, _TIER_TRIAL, _PARTICIPANT;
    • roles: KEYCLOAK_ROLE_ORGS, _RUNNERS, _RENOVATE (the last only when RENOVATE_ENABLED=true).
  • KEYCLOAK_URL must be an internal address, because the edge blocks /admin/*.

Checks

  • 150 tests pass in 7 files. keycloak-http.ts is at 97% statements.
  • Covered cases:
    • group-inherited entitlement;
    • direct ent_renovate;
    • multi-page reads;
    • a failure on page 2 fails closed;
    • token refresh;
    • a missing group or role.
  • Typecheck, eslint, prettier and build pass. podman build passes.

Not verified

No live Keycloak yet. The staging dry run against the realm from bitborg/bitborg-infra#571 confirms the endpoints, paging and the client's permissions.

Refs #78

The reconciler reads identities and entitlements from Keycloak's admin REST API instead of Kanidm (ADR 0044). **Breaking: 2.0.0.** Do not tag `v2.0.0` until a dry run against the staging realm passes. ## What - **Client:** `src/keycloak-http.ts` replaces the Kanidm client. - Gets a client-credentials token as `bitborg-reconciler`, cached and refreshed before expiry. - Reads users (with attributes), group members, and realm roles with their users and groups. - Every list is paged (`first`/`max`, 100 per page). Any failed page aborts the run. - A missing group or role aborts instead of reading as empty. - **Expansion:** a role's members are its direct users plus the members of each group the role is mapped onto. That is the ADR 0044 tier-group model. - **Safety:** - Reads stay fail-closed, and Keycloak is read before any Forgejo write. - The all-tiers-empty refusal stays. - The join key is unchanged: the Keycloak user id against Forgejo `login_name`. - **Display name:** from user attribute `displayName`, falling back to `firstName lastName`. An absent value stays absent, so the never-clear rule holds. ## Configuration (breaking) - `KEYCLOAK_URL`, `KEYCLOAK_REALM`, `KEYCLOAK_CLIENT_ID` and `KEYCLOAK_CLIENT_SECRET` replace `KANIDM_URL` and `KANIDM_TOKEN`. - The `KANIDM_GROUP_*` variables split by kind: - tier groups: `KEYCLOAK_GROUP_TIER_BASIC`, `_TIER_PRO`, `_TIER_TRIAL`, `_PARTICIPANT`; - roles: `KEYCLOAK_ROLE_ORGS`, `_RUNNERS`, `_RENOVATE` (the last only when `RENOVATE_ENABLED=true`). - `KEYCLOAK_URL` must be an internal address, because the edge blocks `/admin/*`. ## Checks - 150 tests pass in 7 files. `keycloak-http.ts` is at 97% statements. - Covered cases: - group-inherited entitlement; - direct `ent_renovate`; - multi-page reads; - a failure on page 2 fails closed; - token refresh; - a missing group or role. - Typecheck, eslint, prettier and build pass. `podman build` passes. ## Not verified No live Keycloak yet. The staging dry run against the realm from bitborg/bitborg-infra#571 confirms the endpoints, paging and the client's permissions. Refs #78
supernaut lade till 2 incheckningar 2026-10-08 20:15:59 +00:00
Replace the Kanidm client with a Keycloak admin REST client
(client_credentials, read-only). Tier groups are read directly. Entitlement
roles expand to direct user mappings plus the members of the groups the role
is mapped onto. The join key stays the user id.

BREAKING CHANGE: KANIDM_URL and KANIDM_TOKEN are replaced by KEYCLOAK_URL,
KEYCLOAK_REALM, KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET. The
KANIDM_GROUP_* variables become KEYCLOAK_GROUP_* for tiers and
KEYCLOAK_ROLE_* for entitlements.

Refs #78
chore(release): 2.0.0
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m13s
ed2eaa2983
Refs #78
supernaut sammanfogade incheckning db4b7968a1 till main 2026-10-08 20:23:27 +00:00
supernaut tog bort grenen feat/keycloak-client 2026-10-08 20:23:27 +00:00
supernaut refererade denna ändringsförfrågan från en incheckning 2026-10-08 20:23:29 +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-auth-reconciler!79
Ingen beskrivning angiven.