Create accounts through the Keycloak admin API #311

Stängd
öppnade 2026-10-08 14:52:48 +00:00 av supernaut · 3 kommentarer
Ägare

Replace src/lib/kanidm.ts with a Keycloak admin client.

  • src/lib/keycloak.ts: client-credentials token for bitborg-web-admin. Create user (username, email, display name, email unverified, groups), send action email for first enrolment, look up by exact email, delete on sign-up rollback, group and role writes. Map 409 and 400 to the existing UI messages.
  • Sign-up: the user picks passkey or password. The portal sets the matching required actions and Keycloak sends the link, which also verifies the email. The resend form keeps captcha and rate limit.
  • Renovate toggle writes the ent_renovate role mapping, then triggerReconcile.
  • session.ts: groups are bare names. Read entitlements for the panel.
  • identity-rules.ts: drop the Kanidm name rules, keep the Forgejo intersection, add Keycloak username rules.
  • oidc.ts: issuer https://auth.bitborg.se/realms/bitborg, check client auth and RS256, logout through the end-session endpoint.
  • Env KEYCLOAK_URL, KEYCLOAK_REALM, KEYCLOAK_ADMIN_CLIENT_ID, KEYCLOAK_ADMIN_CLIENT_SECRET replace KANIDM_*.
  • Pin web_image_tag to the current release before merging, test on staging, unpin at cutover (prod tracks latest).

Done when: sign-up, sign-in and logout work against staging Keycloak.

Depends on: bitborg/bitborg-infra#571
Depends on: web#309
Epic: bitborg/bitborg-docs#127

Replace `src/lib/kanidm.ts` with a Keycloak admin client. - [ ] `src/lib/keycloak.ts`: client-credentials token for `bitborg-web-admin`. Create user (username, email, display name, email unverified, groups), send action email for first enrolment, look up by exact email, delete on sign-up rollback, group and role writes. Map 409 and 400 to the existing UI messages. - [ ] Sign-up: the user picks passkey or password. The portal sets the matching required actions and Keycloak sends the link, which also verifies the email. The resend form keeps captcha and rate limit. - [ ] Renovate toggle writes the `ent_renovate` role mapping, then `triggerReconcile`. - [ ] `session.ts`: groups are bare names. Read `entitlements` for the panel. - [ ] `identity-rules.ts`: drop the Kanidm name rules, keep the Forgejo intersection, add Keycloak username rules. - [ ] `oidc.ts`: issuer `https://auth.bitborg.se/realms/bitborg`, check client auth and RS256, logout through the end-session endpoint. - [ ] Env `KEYCLOAK_URL`, `KEYCLOAK_REALM`, `KEYCLOAK_ADMIN_CLIENT_ID`, `KEYCLOAK_ADMIN_CLIENT_SECRET` replace `KANIDM_*`. - [ ] Pin `web_image_tag` to the current release before merging, test on staging, unpin at cutover (prod tracks `latest`). Done when: sign-up, sign-in and logout work against staging Keycloak. Depends on: bitborg/bitborg-infra#571 Depends on: web#309 Epic: bitborg/bitborg-docs#127
supernaut lade till detta till projektet Bitborg Web 2026-10-08 14:56:15 +00:00
Upphovsperson
Ägare

While moving provisioning to the Keycloak admin API, fix the order in src/pages/api/signup.ts.

Today the account is created first and the consent row second. If the consent write fails, the retry returns taken before the consent write. The row is never written and the user is told the name is taken.

Fix: write the consent row first with onConflictDoNothing. Delete it if provisioning fails and this call inserted it. Add a test where the consent write throws and the retry succeeds.

Done when a failed consent write followed by a retry ends with exactly one account and one consent row.

While moving provisioning to the Keycloak admin API, fix the order in `src/pages/api/signup.ts`. Today the account is created first and the consent row second. If the consent write fails, the retry returns `taken` before the consent write. The row is never written and the user is told the name is taken. Fix: write the consent row first with `onConflictDoNothing`. Delete it if provisioning fails and this call inserted it. Add a test where the consent write throws and the retry succeeds. Done when a failed consent write followed by a retry ends with exactly one account and one consent row.
Upphovsperson
Ägare

Reopened: merged in #328 and running on staging (login redirects to the staging realm). Done-when still needs sign-up, sign-in and logout verified on staging.

Reopened: merged in #328 and running on staging (login redirects to the staging realm). Done-when still needs sign-up, sign-in and logout verified on staging.
supernaut återöppnade detta ärende 2026-10-09 19:13:44 +00:00
Upphovsperson
Ägare

Done on staging, 2026-10-11:

  • Sign-up with a new address: activation mail with the activation subject, account created in Keycloak.
  • Sign-in with password plus one-time code, and with a passkey; supernaut landed on its existing Forgejo account.
  • Logout from /account ends the Bitborg-id session without a confirm page, after #343 (CSP form-action).

Forgejo sign-out keeps the Bitborg-id session by design for now; single logout is bitborg/bitborg-infra#646.

Done on staging, 2026-10-11: - Sign-up with a new address: activation mail with the activation subject, account created in Keycloak. - Sign-in with password plus one-time code, and with a passkey; `supernaut` landed on its existing Forgejo account. - Logout from `/account` ends the Bitborg-id session without a confirm page, after #343 (CSP `form-action`). Forgejo sign-out keeps the Bitborg-id session by design for now; single logout is bitborg/bitborg-infra#646.
Logga in för att delta i denna konversation.
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-web#311
Ingen beskrivning angiven.