Skip to content

Commit 66c96b4

Browse files
authored
fix(dashboard): stop requesting offline_access so logout can revoke sessions (#3447)
## What this PR does The dashboard and linstor-gui auth-proxies (oauth2-proxy) requested the `offline_access` scope, so Keycloak issued an **offline** refresh token. oauth2-proxy has no server-side session store: it keeps the refresh token in the `kc-access` cookie and silently refreshes it (`--cookie-refresh`). An offline token is decoupled from the SSO session by design, so logout (`end_session`) does not revoke it. As a result a copied `kc-access` cookie stayed usable for the whole offline-session lifetime (Keycloak default ~30 days) even after the user logged out — logout did not invalidate it. This drops `offline_access` from the proxy `--scope` in both packages, so Keycloak issues an **online** refresh token bound to the SSO session, which logout revokes. The `offline_access` optional client scope is also removed for cleanliness (with a note on why). Scope of the fix: - `packages/system/dashboard` — proxy `--scope` + optional client scope - `packages/system/linstor-gui` — proxy `--scope` + optional client scope + ingress auth unittest The public `kubernetes` OIDC clients (kubectl `oidc-login`) are intentionally left untouched: `offline_access` is legitimate there and those clients do not sit behind oauth2-proxy. Notes: - The keycloak-operator only *adds* client scopes, so removing the optional scope does not strip the realm-default `offline_access` from an already-created client. The proxy `--scope` change is what actually prevents issuance. - This prevents *new* offline tokens. Offline sessions already issued to existing users remain valid until the realm's offline-session idle timeout (~30d) or explicit revocation via the Keycloak Admin REST API / Account Console. - After this change dashboard session lifetime is governed by the online SSO session (`client.session.idle.timeout` / `client.session.max.lifespan`). ### Screenshots Not applicable — no UI change (auth-proxy OIDC scope only). ### Downstream repositories Walked the trigger map against the diff: the change touches only helm templates and a unittest under `packages/system/dashboard` and `packages/system/linstor-gui`. No downstream repository restates the auth-proxy OIDC scope. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: ### Release note ```release-note fix(dashboard): stop requesting the offline_access scope in the dashboard and linstor-gui auth-proxies so that logout revokes the session; a copied kc-access cookie is no longer refreshable after logout. Offline sessions already issued to existing users must be revoked manually via Keycloak. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Security Improvements** * Removed requests for offline access and persistent refresh tokens from OIDC authentication. * Sessions now rely on standard scopes, helping ensure logout invalidates authentication as expected. * **Tests** * Updated authentication checks to verify the revised OIDC scope configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 436743e + 51c34c2 commit 66c96b4

5 files changed

Lines changed: 27 additions & 7 deletions

File tree

‎packages/system/dashboard/templates/gatekeeper.yaml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ spec:
7777
- --cookie-secure=true
7878
- --cookie-secret=$(OAUTH2_PROXY_COOKIE_SECRET)
7979
- --skip-provider-button
80-
- --scope=openid email profile offline_access
80+
# No offline_access: that scope makes Keycloak issue an *offline*
81+
# refresh token, which is decoupled from the SSO session and is NOT
82+
# revoked by logout (end_session). Since oauth2-proxy keeps the
83+
# refresh token in the kc-access cookie and silently refreshes it,
84+
# a copied cookie would stay valid for the whole offline-session
85+
# lifetime (~30d) even after the user logs out. An online refresh
86+
# token is bound to the SSO session and is revoked on logout.
87+
- --scope=openid email profile
8188
{{- if eq $oidcInsecureSkipVerify "true" }}
8289
- --ssl-insecure-skip-verify=true
8390
{{- end }}

‎packages/system/dashboard/templates/keycloakclient.yaml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ spec:
6969
defaultClientScopes:
7070
- groups
7171
- kubernetes-client
72-
optionalClientScopes:
73-
- offline_access
72+
# offline_access is intentionally not offered: an offline refresh token
73+
# survives logout (see the proxy Deployment's --scope). NB the
74+
# keycloak-operator only adds client scopes, so dropping this does not strip
75+
# the realm-default offline_access from an already-created client; the proxy
76+
# --scope change is what prevents issuance.
7477
attributes:
7578
post.logout.redirect.uris: "+"
7679
client.session.idle.timeout: "86400"

‎packages/system/linstor-gui/templates/gatekeeper.yaml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ spec:
8989
- --cookie-secure=true
9090
- --cookie-secret=$(OAUTH2_PROXY_COOKIE_SECRET)
9191
- --skip-provider-button
92-
- --scope=openid email profile groups offline_access
92+
# No offline_access: that scope makes Keycloak issue an *offline*
93+
# refresh token, which is decoupled from the SSO session and is NOT
94+
# revoked by logout (end_session). Since oauth2-proxy keeps the
95+
# refresh token in the kc-access cookie and silently refreshes it,
96+
# a copied cookie would stay valid for the whole offline-session
97+
# lifetime (~30d) even after the user logs out. An online refresh
98+
# token is bound to the SSO session and is revoked on logout.
99+
- --scope=openid email profile groups
93100
- --allowed-group=cozystack-cluster-admin
94101
{{- if eq $oidcInsecureSkipVerify "true" }}
95102
- --ssl-insecure-skip-verify=true

‎packages/system/linstor-gui/templates/keycloakclient.yaml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ spec:
6363
webUrl: "https://linstor-gui.{{ $host }}"
6464
defaultClientScopes:
6565
- groups
66-
optionalClientScopes:
67-
- offline_access
66+
# offline_access is intentionally not offered: an offline refresh token
67+
# survives logout (see the proxy Deployment's --scope). NB the
68+
# keycloak-operator only adds client scopes, so dropping this does not strip
69+
# the realm-default offline_access from an already-created client; the proxy
70+
# --scope change is what prevents issuance.
6871
attributes:
6972
post.logout.redirect.uris: "+"
7073
redirectUris:

‎packages/system/linstor-gui/tests/ingress_auth_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ tests:
127127
content: --oidc-issuer-url=https://keycloak.dev10.example.org/realms/cozy
128128
- contains:
129129
path: spec.template.spec.containers[0].args
130-
content: --scope=openid email profile groups offline_access
130+
content: --scope=openid email profile groups
131131
- contains:
132132
path: spec.template.spec.containers[0].args
133133
content: --allowed-group=cozystack-cluster-admin

0 commit comments

Comments
 (0)