fix(caddy): end the Bitborg-id session on Forgejo sign-out #755

Sammanfogat
supernaut sammanfogade 3 incheckningar från fix/forgejo-sso-logout in i main 2026-10-15 10:43:45 +00:00
Ägare

Signing out of Forgejo now also ends the Bitborg-id session. Before, the next "Sign in" signed the user straight back in.

Forgejo v16 has no RP-initiated logout, so Caddy on git.* does it:

  • POST /user/logout: the 200 reply is rewritten to {"redirect":"/user/sso-logout"} and sets a 60-second cookie, bitborg_sso_logout. Forgejo's own Set-Cookie headers pass through.
  • Forgejo's JS then navigates to /user/sso-logout, or to / when its event stream reports the logout first. The first navigation with the cookie deletes it and redirects to Keycloak's openid-connect/logout with client_id and post_logout_redirect_uri.
  • Only git.* can set the cookie, so a link from another site cannot sign anyone out. /user/sso-logout without the cookie redirects to /.
  • Keycloak shows its confirm page: Forgejo keeps no id_token for id_token_hint.
  • forgejo_oidc_client_id moves to group_vars/all so the caddy role can read it.

Tested on staging: curl for each path (logout reply and cookies, the / path, a stale or cross-site /user/sso-logout, /user/login and ?local=1 unchanged), and a browser run: sign in, sign out, confirm page, signed out, next sign-in shows the login form.

Closes #646

Signing out of Forgejo now also ends the Bitborg-id session. Before, the next "Sign in" signed the user straight back in. Forgejo v16 has no RP-initiated logout, so Caddy on `git.*` does it: - `POST /user/logout`: the 200 reply is rewritten to `{"redirect":"/user/sso-logout"}` and sets a 60-second cookie, `bitborg_sso_logout`. Forgejo's own `Set-Cookie` headers pass through. - Forgejo's JS then navigates to `/user/sso-logout`, or to `/` when its event stream reports the logout first. The first navigation with the cookie deletes it and redirects to Keycloak's `openid-connect/logout` with `client_id` and `post_logout_redirect_uri`. - Only `git.*` can set the cookie, so a link from another site cannot sign anyone out. `/user/sso-logout` without the cookie redirects to `/`. - Keycloak shows its confirm page: Forgejo keeps no id_token for `id_token_hint`. - `forgejo_oidc_client_id` moves to `group_vars/all` so the caddy role can read it. Tested on staging: curl for each path (logout reply and cookies, the `/` path, a stale or cross-site `/user/sso-logout`, `/user/login` and `?local=1` unchanged), and a browser run: sign in, sign out, confirm page, signed out, next sign-in shows the login form. Closes #646
supernaut lade till 3 incheckningar 2026-10-15 10:37:16 +00:00
supernaut tvångsskickade fix/forgejo-sso-logout från 28ba11e6f6
Väntande kontroller
ci / ci (pull_request) Has started running
till 973eb3fa0b
Alla kontroller lyckades
ci / ci (pull_request) Successful in 2m48s
2026-10-15 10:40:20 +00:00
Jämför
supernaut schemalade den här ändringsförfrågan för automatisk sammanfogning när alla kontroller lyckas 2026-10-15 10:40:29 +00:00
supernaut sammanfogade incheckning 2c8788d9af till main 2026-10-15 10:43:45 +00:00
supernaut tog bort grenen fix/forgejo-sso-logout 2026-10-15 10:43:45 +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!755
Ingen beskrivning angiven.