keycloak: admin console does not load through the sshd forward #644

Öppen
öppnade 2026-10-10 17:30:50 +00:00 av supernaut · 2 kommentarer
Ägare

What

The Keycloak admin console does not load through the sshd forward. Opening http://127.0.0.1:18080/admin/master/console/ spins, then shows:

Timeout when waiting for 3rd party check iframe message.

Seen on staging with image 26.8.0-3. The admin REST API through the same forward works.

Why

KC_HOSTNAME is the public URL (keycloak.container.j2). The console builds its URLs from it, so it loads the third-party-cookie check iframe from https://id.stg.bitborg.se/realms/master/.... Caddy answers 404 for everything outside /realms/bitborg/* and /resources/*, so the iframe never posts its message.

Today every realm change goes through OpenTofu or the admin API, so nothing depends on the console. It is still the fastest tool for break-glass inspection, and the runbook's "Reach the admin API" section does not say the console is unavailable.

Fix

Set KC_HOSTNAME_ADMIN=http://127.0.0.1:18080 so the console and its master-realm calls stay on the forward. The public edge stays as it is. Verify on staging that the console loads and signs in through the forward, and that the public hostname and issuer do not change.

If the console is not wanted, say so in the runbook section instead.

Done when

  • The admin console loads through the forward on staging, or the runbook states that only the API is available.
  • Token iss for the bitborg realm is unchanged.
## What The Keycloak admin console does not load through the sshd forward. Opening `http://127.0.0.1:18080/admin/master/console/` spins, then shows: > Timeout when waiting for 3rd party check iframe message. Seen on staging with image `26.8.0-3`. The admin REST API through the same forward works. ## Why `KC_HOSTNAME` is the public URL (`keycloak.container.j2`). The console builds its URLs from it, so it loads the third-party-cookie check iframe from `https://id.stg.bitborg.se/realms/master/...`. Caddy answers 404 for everything outside `/realms/bitborg/*` and `/resources/*`, so the iframe never posts its message. Today every realm change goes through OpenTofu or the admin API, so nothing depends on the console. It is still the fastest tool for break-glass inspection, and the runbook's "Reach the admin API" section does not say the console is unavailable. ## Fix Set `KC_HOSTNAME_ADMIN=http://127.0.0.1:18080` so the console and its master-realm calls stay on the forward. The public edge stays as it is. Verify on staging that the console loads and signs in through the forward, and that the public hostname and issuer do not change. If the console is not wanted, say so in the runbook section instead. ## Done when - [ ] The admin console loads through the forward on staging, or the runbook states that only the API is available. - [ ] Token `iss` for the `bitborg` realm is unchanged.
Upphovsperson
Ägare

Partly explained by #647: the shared Caddy headers sent X-Frame-Options: DENY on the Keycloak vhost, which blocked the console's same-origin cookie-check iframe. That fixed the account console on id.stg.

The admin console through the forward is still a separate case. It is served from 127.0.0.1:18080 but loads the iframe from https://id.stg.bitborg.se, which is cross-origin, and Keycloak's frame-ancestors 'self' blocks that. KC_HOSTNAME_ADMIN remains the proposed fix.

Partly explained by #647: the shared Caddy headers sent `X-Frame-Options: DENY` on the Keycloak vhost, which blocked the console's same-origin cookie-check iframe. That fixed the account console on `id.stg`. The admin console through the forward is still a separate case. It is served from `127.0.0.1:18080` but loads the iframe from `https://id.stg.bitborg.se`, which is cross-origin, and Keycloak's `frame-ancestors 'self'` blocks that. `KC_HOSTNAME_ADMIN` remains the proposed fix.
Upphovsperson
Ägare

Status 2026-10-21, parked.

KC_HOSTNAME_ADMIN=http://127.0.0.1:18080 is live on staging. The console HTML now has authUrl: http://127.0.0.1:18080, and the bitborg issuer is unchanged. The console still fails with "Timeout when waiting for 3rd party check iframe message".

Cause: the console's authServerUrl is still https://id.stg.bitborg.se. The 3p-cookie iframe loads <authServerUrl>/realms/master/protocol/openid-connect/3p-cookies/step1.html, and Caddy serves only the bitborg realm publicly, so that URL returns 404.

Proposed fix, untested: set the master realm attribute frontendUrl to http://127.0.0.1:18080. Every master consumer in this repo (OpenTofu, the keycloak role's admin calls) already uses that URL. If a manual test on staging works, add it to the keycloak role next to the adminEventsExpiration task.

The manual test stopped at getting a token: a password grant for the temporary admin on admin-cli returned no access_token. The error body was not read yet. Next: print the raw token response, or use the opentofu client token from scripts/keycloak-tofu-env.py staging.

A temporary master admin from bootstrap-admin user may still exist on staging. Delete it.

Status 2026-10-21, parked. `KC_HOSTNAME_ADMIN=http://127.0.0.1:18080` is live on staging. The console HTML now has `authUrl: http://127.0.0.1:18080`, and the `bitborg` issuer is unchanged. The console still fails with "Timeout when waiting for 3rd party check iframe message". Cause: the console's `authServerUrl` is still `https://id.stg.bitborg.se`. The 3p-cookie iframe loads `<authServerUrl>/realms/master/protocol/openid-connect/3p-cookies/step1.html`, and Caddy serves only the `bitborg` realm publicly, so that URL returns 404. Proposed fix, untested: set the master realm attribute `frontendUrl` to `http://127.0.0.1:18080`. Every master consumer in this repo (OpenTofu, the keycloak role's admin calls) already uses that URL. If a manual test on staging works, add it to the keycloak role next to the `adminEventsExpiration` task. The manual test stopped at getting a token: a password grant for the temporary admin on `admin-cli` returned no `access_token`. The error body was not read yet. Next: print the raw token response, or use the `opentofu` client token from `scripts/keycloak-tofu-env.py staging`. A temporary master admin from `bootstrap-admin user` may still exist on staging. Delete it.
Logga in för att delta i denna konversation.
Ingen milstolpe
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#644
Ingen beskrivning angiven.