Skip to content

Commit 1699958

Browse files
committed
fix(auth): fix admin permissions and logout redirection
1 parent 7f2f6a1 commit 1699958

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.github/workflows/deploy-lgtm-gke.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ permissions:
3737
contents: read
3838
pull-requests: write
3939
id-token: write
40+
actions: write
4041

4142
env:
4243
TERRAFORM_VERSION: '1.6.0'

lgtm-stack/terraform/keycloak.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ resource "keycloak_openid_client" "grafana" {
3636
admin_url = "https://grafana.${var.monitoring_domain}"
3737

3838
valid_redirect_uris = [
39-
"https://grafana.${var.monitoring_domain}/login/generic_oauth"
39+
"https://grafana.${var.monitoring_domain}/login/generic_oauth",
40+
# Required for KC 18+ post-logout redirect — must match the URI
41+
# passed in signout_redirect_url's post_logout_redirect_uri param.
42+
"https://grafana.${var.monitoring_domain}/login"
4043
]
4144

4245
web_origins = [

lgtm-stack/terraform/values/grafana-values.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,15 @@ grafana.ini:
9393
role_attribute_path: "contains(roles[*], 'grafana-admin') && 'Admin' || contains(roles[*], 'grafana-editor') && 'Editor' || contains(roles[*], 'grafana-viewer') && 'Viewer'"
9494

9595
# STRICT: if a user has no matching role, their login is REJECTED.
96-
# This blocks any netbird-realm user who isn't in a grafana-* group.
96+
# This blocks any argocd-realm user who isn't in a grafana-* group.
9797
role_attribute_strict: true
9898

99+
# Promote OAuth Admins to Grafana Server Admin so they can manage
100+
# all users via Administration → Users and access.
101+
# Without this, OAuth users are only Org Admins and get
102+
# 'org.users:read / org.users:add' permission errors.
103+
allow_assign_grafana_admin: true
104+
99105
# ---- Group-Based Access Control (via groups[] claim) ----
100106
# Only users in one of these groups can log in. Everyone else
101107
# in the netbird realm is completely blocked from Grafana.
@@ -106,9 +112,11 @@ grafana.ini:
106112
# Requires 'offline_access' in scopes (already set above).
107113
use_refresh_token: true
108114

109-
# Single Logout: after signing out of Grafana, the user is
110-
# also logged out of Keycloak and redirected back to login.
111-
signout_redirect_url: ${keycloak_url}/realms/${keycloak_realm}/protocol/openid-connect/logout?post_logout_redirect_uri=https%3A%2F%2Fgrafana.${monitoring_domain}%2Flogin
115+
# Single Logout: signs the user out of Keycloak then redirects
116+
# back to Grafana's login page.
117+
# KC 18+ requires client_id (or id_token_hint) for post_logout_redirect_uri
118+
# to be honoured — without it the user lands on a blank Keycloak page.
119+
signout_redirect_url: ${keycloak_url}/realms/${keycloak_realm}/protocol/openid-connect/logout?client_id=grafana-oauth&post_logout_redirect_uri=https%3A%2F%2Fgrafana.${monitoring_domain}%2Flogin
112120

113121
datasources:
114122
datasources.yaml:

0 commit comments

Comments
 (0)