Grafana
Ce guide vous explique comment configurer l'authentification unique (SSO) entre SmartLink et Grafana en utilisant OpenID Connect. Grafana offre un support natif excellent pour OAuth2/OpenID Connect.
Prérequis
- Grafana version 7.0 ou supérieure
- Accès administrateur à Grafana
- Application configurée dans SmartLink avec OpenID Connect
- HTTPS configuré sur Grafana (recommandé)
Configuration dans SmartLink
1. Créer l'application
- Connectez-vous à SmartLink en tant qu'administrateur
- Allez dans Applications → Ajouter
- Créez une nouvelle application :
- Nom : Grafana
- URL :
https://grafana.example.com - Description : Plateforme de monitoring et observabilité
- Icône : Choisissez l'icône Grafana
2. Configurer OpenID Connect
- Dans l'onglet Authentification
- Sélectionnez OpenID Connect
- Notez les informations :
- Client ID :
grafana-xxxxxx - Client Secret :
secret-xxxxxx - Issuer URL :
https://votre-smartlink.link.vaultys.org/api/oidc/[appid] - App ID :
[appid](identifiant unique de l'application dans SmartLink)
- Client ID :
3. URLs de redirection
Ajoutez dans URLs de redirection autorisées :
https://grafana.example.com/login/generic_oauth
4. Scopes et claims
Scopes requis :
openidprofileemailgroups(pour le mapping des rôles)
Configuration dans Grafana
1. Configuration via fichier INI
Éditez /etc/grafana/grafana.ini ou /conf/grafana.ini :
#################################### Auth ####################################
[auth]
# Désactiver la création de compte via l'interface
disable_login_form = false
disable_signout_menu = false
# OAuth auto login
oauth_auto_login = true
# Synchronisation automatique des équipes
oauth_allow_insecure_email_lookup = false
#################################### Generic OAuth ##########################
[auth.generic_oauth]
enabled = true
name = SmartLink SSO
allow_sign_up = true
auto_login = false
client_id = grafana-xxxxxx
client_secret = secret-xxxxxx
scopes = openid profile email groups
email_attribute_name = email
email_attribute_path = email
login_attribute_path = email
name_attribute_path = name
groups_attribute_path = groups
role_attribute_path = contains(groups[*], 'grafana-admins') && 'Admin' || contains(groups[*], 'grafana-editors') && 'Editor' || 'Viewer'
role_attribute_strict = false
allow_assign_grafana_admin = true
auth_url = https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/authorize
token_url = https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/token
api_url = https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/userinfo
signout_redirect_url = https://votre-smartlink.link.vaultys.org/logout
use_pkce = true
use_refresh_token = true
# Mapping des équipes (optionnel)
team_ids_attribute_path = groups
teams_url = https://votre-smartlink.link.vaultys.org/api/teams
2. Configuration via variables d'environnement
Pour Docker ou Kubernetes :
version: '3.8'
services:
grafana:
image: grafana/grafana:latest
environment:
# Configuration OAuth
- GF_AUTH_GENERIC_OAUTH_ENABLED=true
- GF_AUTH_GENERIC_OAUTH_NAME=SmartLink SSO
- GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP=true
- GF_AUTH_GENERIC_OAUTH_CLIENT_ID=grafana-xxxxxx
- GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET=secret-xxxxxx
- GF_AUTH_GENERIC_OAUTH_SCOPES=openid profile email groups
- GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_NAME=email
- GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_PATH=email
- GF_AUTH_GENERIC_OAUTH_LOGIN_ATTRIBUTE_PATH=email
- GF_AUTH_GENERIC_OAUTH_NAME_ATTRIBUTE_PATH=name
- GF_AUTH_GENERIC_OAUTH_AUTH_URL=https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/authorize
- GF_AUTH_GENERIC_OAUTH_TOKEN_URL=https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/token
- GF_AUTH_GENERIC_OAUTH_API_URL=https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/userinfo
- GF_AUTH_GENERIC_OAUTH_USE_PKCE=true
# Auto login
- GF_AUTH_OAUTH_AUTO_LOGIN=true
# Désactiver l'authentification anonyme
- GF_AUTH_ANONYMOUS_ENABLED=false
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
volumes:
grafana-data:
3. Configuration Helm (Kubernetes)
# values.yaml pour le chart Grafana
grafana:
grafana.ini:
auth:
oauth_auto_login: true
auth.generic_oauth:
enabled: true
name: SmartLink SSO
allow_sign_up: true
client_id: grafana-xxxxxx
client_secret: secret-xxxxxx
scopes: openid profile email groups
auth_url: https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/authorize
token_url: https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/token
api_url: https://votre-smartlink.link.vaultys.org/api/oidc/[appid]/userinfo
role_attribute_path: |
contains(groups[*], 'grafana-admins') && 'Admin' ||
contains(groups[*], 'grafana-editors') && 'Editor' ||
'Viewer'