fix(grafana): use email for OAuth login lookup instead of preferred_username

- Change login_attribute_path from preferred_username to email for stable user matching
- Enable allow_sign_up to permit OAuth user sync with existing local users
- Root cause: Authentik's 'rock' user matches existing Grafana 'rock' by email, not by preferred_username claim
This commit is contained in:
2026-09-15 00:01:10 +09:00
parent 7e91262257
commit 467b3441c9
+2 -2
View File
@@ -73,7 +73,7 @@ grafana.ini:
auth.generic_oauth: auth.generic_oauth:
enabled: true enabled: true
name: Authentik name: Authentik
allow_sign_up: false allow_sign_up: true # Allow sync to create/update users from OAuth claims
client_id: grafana client_id: grafana
scopes: openid email profile groups scopes: openid email profile groups
auth_url: https://authentik.riotpiao.com/application/o/authorize/ auth_url: https://authentik.riotpiao.com/application/o/authorize/
@@ -84,7 +84,7 @@ grafana.ini:
# Authentik doesn't serve — request 404s with "Error getting email address" # Authentik doesn't serve — request 404s with "Error getting email address"
# and the whole OAuth login fails. # and the whole OAuth login fails.
email_attribute_path: email email_attribute_path: email
login_attribute_path: preferred_username login_attribute_path: email # Use email for lookup — stable and matches Authentik
name_attribute_path: name name_attribute_path: name
role_attribute_path: "preferred_username == 'akadmin' && 'GrafanaAdmin' || contains(groups[*], 'homelab-admins') && 'Admin' || 'Viewer'" role_attribute_path: "preferred_username == 'akadmin' && 'GrafanaAdmin' || contains(groups[*], 'homelab-admins') && 'Admin' || 'Viewer'"
allow_assign_grafana_admin: true allow_assign_grafana_admin: true