fix(auth): add email fallback scope for Grafana OAuth and set attribute paths
ansible-core-mon / deploy (push) Successful in 9s
ansible-core-net / deploy (push) Successful in 18s

This commit is contained in:
karpenok committed 2026-11-11 17:07:00 +07:00
1 parent 811d65526b
commit 94a143623b
2 files changed
+19 -1

No files matched your search

@@ -66,6 +66,10 @@ services:
- GF_AUTH_GENERIC_OAUTH_TOKEN_URL=https://auth.gunihome.ru/application/o/token/
- GF_AUTH_GENERIC_OAUTH_API_URL=https://auth.gunihome.ru/application/o/userinfo/
- GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP=true
- GF_AUTH_GENERIC_OAUTH_LOGIN_ATTRIBUTE_PATH=preferred_username
- GF_AUTH_GENERIC_OAUTH_NAME_ATTRIBUTE_PATH=name
- GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_PATH=email
- GF_AUTH_GENERIC_OAUTH_USE_PKCE=true
- "GF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_PATH=contains(groups[*], 'admins') && 'Admin' || 'Viewer'"
- GF_AUTH_GENERIC_OAUTH_ALLOW_ASSIGN_GRAFANA_ADMIN=true
volumes:
@@ -15,6 +15,20 @@ entries:
identifiers:
name: family
- model: authentik_providers_oauth2.scopemapping
id: scope-grafana-email
identifiers:
managed: homelab/providers/oauth2/scope-grafana-email
attrs:
name: "Grafana OAuth Mapping: OpenID 'email' with fallback"
scope_name: email
description: "Email scope with fallback for users without email"
expression: |
return {
"email": request.user.email or f"{request.user.username}@gunihome.ru",
"email_verified": True
}
- model: authentik_providers_oauth2.oauth2provider
id: provider-grafana
identifiers:
@@ -31,7 +45,7 @@ entries:
signing_key: !Find [authentik_crypto.certificatekeypair, [name, "authentik Self-signed Certificate"]]
property_mappings:
- !Find [authentik_providers_oauth2.scopemapping, [scope_name, openid]]
- !Find [authentik_providers_oauth2.scopemapping, [scope_name, email]]
- !KeyOf scope-grafana-email
- !Find [authentik_providers_oauth2.scopemapping, [scope_name, profile]]
- model: authentik_core.application