keycloak: end the forgejo session on portal sign-out #756
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#756
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?
What
Signing out on the portal ends the portal session and the Bitborg ID (Keycloak) session. The Forgejo session at git.bitborg.se stays open until the person signs out there or it expires. On a shared computer the next person can still use git.bitborg.se as them.
The other direction works since #646: Forgejo sign-out also ends the Bitborg ID session.
Options to evaluate
Done when
accounts-signout(bitborg-web, English and Swedish) no longer advises signing out in both places.Next step: reproduce on staging in a browser. Sign in through the portal, open Forgejo, sign out on the portal, then reload Forgejo. Then check whether a front-channel logout URL on the Keycloak
forgejoclient, served through Caddy as in #646, ends the Forgejo session. Curl cannot show this, because the race in #646 happens only in a browser.Not started yet. Reproducing this needs a signed-in staging browser session, and the SAQ A checkout check on staging uses the same session, so that check goes first. Next step: reproduce on stg in a browser, then test a front-channel logout URL on the Keycloak
forgejoclient, served through Caddy as in #646.Reproduced on staging in a browser, 2026-10-17.
client_id=bitborg-web, withid_token_hint). Keycloak showed a "Do you want to log out?" confirmation page. Confirmed.Cause: the portal sign-out ends only the portal and Keycloak sessions. Nothing tells Forgejo, and Forgejo v16 has no OIDC logout endpoint.
Triage: go with front-channel logout on the Keycloak
forgejoclient. The URL is a Caddy endpoint on the Forgejo host that expires the Forgejo session cookies, in the style of #646. Open questions for the change: framing (the globalX-Frame-Options), the server-side session, and limiting who can trigger the endpoint. Side finding: the confirmation page appears despiteid_token_hint. Looking into it with the change.Change is in PR #760. Merge after the staging apply and browser test listed there.
Staging apply of #760, 2026-10-17, from
mainatbe2f5d3(the PR was already merged; tree equal to2c5a2dc).opentofu/keycloak, workspacestaging: 0 added, 1 changed, 0 destroyed. Onlykeycloak_openid_client.sign_in["forgejo"]:frontchannel_logout_enabledtrue,frontchannel_logout_urlhttps://git.stg.bitborg.se/user/frontchannel-logout.--tags caddyonbitborg-staging:changed=2(Caddyfile, restart),failed=0. Diff was only the@forgejo_frontchannel_logoutblock.Curl checks:
404,X-Frame-Options: DENY. As expected.GETwithSec-Fetch-Dest: iframe,Sec-Fetch-Site: same-siteand theissquery:200,Content-Security-Policy: frame-ancestors https://id.stg.bitborg.se,persistentandredirect_tocookies expired (Max-Age=0).X-Frame-Options: DENYis still on the200response. The site-widesecurity_headerssnippet sets it after the inner-X-Frame-Optionsruns. Browsers ignoreX-Frame-Optionswhen the CSP hasframe-ancestors, so the browser test decides whether this needs a fix.HEADrequest does not match (method GET) and gets404. Expected.Browser test next.
Browser test on staging, 2026-10-17, Chrome, account
signup-test-free. All four steps pass.GET git.stg.bitborg.se/user/frontchannel-logout?iss=…&sid=…,200,Sec-Fetch-Dest: iframe,Sec-Fetch-Site: same-site.git.stg.bitborg.se: signed out. "Sign in" showed the Keycloak login form.issin the address bar gives404, and the user stays signed in.client_id=forgejo), then back to Forgejo signed out. The next "Sign in" shows the login form.The extra
X-Frame-Options: DENYon the200did not stop the sign-out. Follow-up to drop the dead-X-Frame-Optionsline and its test assertion is open for decision.Left for this issue: the bitborg-web FAQ
accounts-signoutPR.FAQ PR: bitborg/bitborg-web#399. Merge it only after #760 is applied on prod.
Follow-up PR #761 drops the no-op
-X-Frame-Optionsfrom the front-channel handle, its test assertion and the runbook claim. After merge:--tags caddyon staging and prod.Prod apply, 2026-10-17, from
main(be2f5d3):opentofu/keycloak, workspaceprod: 0 added, 1 changed, 0 destroyed. Onlykeycloak_openid_client.sign_in["forgejo"]:frontchannel_logout_enabledtrue,frontchannel_logout_urlhttps://git.bitborg.se/user/frontchannel-logout.--tags caddyonbitborg-prod:--check --diffshowed only the@forgejo_frontchannel_logoutblock; applychanged=2,failed=0.Curl checks on
git.bitborg.se: bare URL404withX-Frame-Options: DENY; iframe-shapedGETwith the realm'siss200,frame-ancestors https://id.bitborg.se,persistentandredirect_toexpired.X-Frame-Options: DENYalso on the200, as on staging (#761).Done: #760 and #761 merged and applied on staging and prod (operator ran
--tags caddyon both after #761), FAQ bitborg/bitborg-web#399 merged. Front-channel URL re-checked on both envs: iframe-shaped GET 200, bare URL 404. Side finding tracked in bitborg/bitborg-web#398.