Set up Grafana Enterprise SSO authentication with LDAP, SAML, and OAuth2 integration

Advanced 45 min Apr 17, 2026 277 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Configure Grafana Enterprise with comprehensive single sign-on authentication supporting LDAP, SAML, and OAuth2 providers. Set up role-based access control with automated team mapping and user provisioning for enterprise environments.

Prerequisites

  • Grafana Enterprise license
  • Active Directory or LDAP server
  • SAML identity provider access
  • OAuth2 application credentials
  • SSL certificates for SAML

What this solves

Grafana Enterprise SSO authentication eliminates the need for separate user credentials by integrating with your existing identity providers. This tutorial configures LDAP authentication with Active Directory, SAML integration with enterprise identity providers, and OAuth2 with Google and GitHub. You'll implement role-based access control with automatic team mapping to streamline user management across your monitoring infrastructure.

Step-by-step installation

Install Grafana Enterprise

Download and install Grafana Enterprise which includes SSO features not available in the open source version.

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana-enterprise
cat > /etc/yum.repos.d/grafana.repo << EOF
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
EOF
sudo dnf install -y grafana-enterprise

Configure Grafana Enterprise license

Add your Grafana Enterprise license key to enable SSO features.

[enterprise]
license_path = /etc/grafana/license.jwt

Create the license file with your Enterprise license token:

sudo touch /etc/grafana/license.jwt
sudo chown grafana:grafana /etc/grafana/license.jwt
sudo chmod 640 /etc/grafana/license.jwt
echo "your-license-jwt-token-here" | sudo tee /etc/grafana/license.jwt

Configure LDAP authentication

Set up LDAP integration with Active Directory for enterprise user authentication.

[[servers]]
host = "ldap.example.com"
port = 636
use_ssl = true
start_tls = false
ssl_skip_verify = false
bind_dn = "cn=grafana,ou=service-accounts,dc=example,dc=com"
bind_password = "secure-bind-password"
search_filter = "(sAMAccountName=%s)"
search_base_dns = ["ou=users,dc=example,dc=com"]

[servers.attributes]
name = "givenName"
surname = "sn"
username = "sAMAccountName"
member_of = "memberOf"
email = "mail"

[[servers.group_mappings]]
group_dn = "cn=grafana-admins,ou=groups,dc=example,dc=com"
org_role = "Admin"
grafana_admin = true

[[servers.group_mappings]]
group_dn = "cn=grafana-editors,ou=groups,dc=example,dc=com"
org_role = "Editor"

[[servers.group_mappings]]
group_dn = "cn=grafana-viewers,ou=groups,dc=example,dc=com"
org_role = "Viewer"

Enable LDAP authentication in Grafana

Update the main Grafana configuration to enable LDAP authentication.

[auth.ldap]
enabled = true
config_file = /etc/grafana/ldap.toml
allow_sign_up = true
sync_cron = "0 0 1   *"
active_sync_enabled = true

Configure SAML authentication

Set up SAML integration for enterprise identity providers like Okta, Azure AD, or ADFS.

[auth.saml]
enabled = true
certificate_path = /etc/grafana/saml.crt
private_key_path = /etc/grafana/saml.key
idp_metadata_url = https://example.okta.com/app/exampleapp/sso/saml/metadata
max_issue_delay = 90s
metadata_valid_duration = 48h
allow_idp_initiated = true
allow_sign_up = true
auto_login = false
single_logout = true
name_id_format = urn:oasis:names:tc:SAML:2.0:nameid-format:persistent

Generate SAML certificates

Create SSL certificates for SAML authentication security.

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout /etc/grafana/saml.key \
  -out /etc/grafana/saml.crt \
  -subj "/C=US/ST=State/L=City/O=Organization/CN=grafana.example.com"
sudo chown grafana:grafana /etc/grafana/saml.*
sudo chmod 640 /etc/grafana/saml.*

Configure SAML attribute mapping

Map SAML attributes to Grafana user properties for automatic user provisioning.

[auth.saml]
attribute_name = Name
attribute_login = Login
attribute_email = Email
attribute_groups = Groups
attribute_role = Role
attribute_org = Org
org_mapping = Engineering:1:Editor,Operations:2:Admin
role_values_editor = Editor,Developer
role_values_admin = Admin,Manager
role_values_grafana_admin = SuperAdmin

Configure OAuth2 with Google

Set up Google OAuth2 authentication for users with Google accounts.

[auth.google]
enabled = true
allow_sign_up = true
client_id = your-google-client-id
client_secret = your-google-client-secret
scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
auth_url = https://accounts.google.com/o/oauth2/auth
token_url = https://accounts.google.com/o/oauth2/token
api_url = https://www.googleapis.com/oauth2/v1/userinfo
allowed_domains = example.com
hosted_domain = example.com

Configure OAuth2 with GitHub

Enable GitHub OAuth2 authentication for development teams using GitHub.

[auth.github]
enabled = true
allow_sign_up = true
client_id = your-github-client-id
client_secret = your-github-client-secret
scopes = user:email,read:org
auth_url = https://github.com/login/oauth/authorize
token_url = https://github.com/login/oauth/access_token
api_url = https://api.github.com/user
allowed_organizations = your-org-name
team_ids = 123456,789012

Configure role-based access control

Set up advanced RBAC with team mapping and organization management.

[users]
allow_sign_up = false
allow_org_create = false
auto_assign_org = true
auto_assign_org_id = 1
auto_assign_org_role = Viewer
verify_email_enabled = true
login_hint = Use your corporate credentials
default_theme = dark
home_page = /dashboards

[auth]
login_cookie_name = grafana_session
login_maximum_inactive_lifetime_duration = 7d
login_maximum_lifetime_duration = 30d
tokent_rotation_interval_minutes = 10
disable_login_form = false
disable_signout_menu = false
signout_redirect_url = https://sso.example.com/logout
oauth_auto_login = false

Configure team synchronization

Enable automatic team synchronization from external identity providers.

[auth]
team_sync_enabled = true

[auth.ldap]
group_search_filter = "(&(objectClass=group)(member=%s))"
group_search_base_dns = ["ou=groups,dc=example,dc=com"]

[auth.saml]
teams_attribute_name = Teams
teams_attribute_path = Teams

[auth.google]
team_ids = 123456789
allowed_organizations = example-org

[auth.github]
team_ids = 123456,789012
allowed_organizations = example-org

Set file permissions and start Grafana

Secure configuration files and start the Grafana service.

Never use chmod 777. It gives every user on the system full access to your files. Instead, fix ownership with chown and use minimal permissions.
sudo chown -R grafana:grafana /etc/grafana/
sudo chmod 755 /etc/grafana
sudo chmod 644 /etc/grafana/grafana.ini
sudo chmod 640 /etc/grafana/ldap.toml
sudo chmod 640 /etc/grafana/license.jwt
sudo systemctl enable --now grafana-server
sudo systemctl status grafana-server

Configure firewall access

Open the Grafana port for web access while maintaining security.

sudo ufw allow 3000/tcp
sudo ufw status
sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports

Configure SSO testing and validation

Test LDAP authentication

Validate LDAP connectivity and user authentication.

sudo grafana-cli admin ldap-test --config=/etc/grafana/grafana.ini
sudo grafana-cli admin ldap-sync --config=/etc/grafana/grafana.ini

Configure SAML metadata exchange

Exchange metadata with your SAML identity provider.

curl -s http://localhost:3000/saml/metadata | sudo tee /var/tmp/grafana-saml-metadata.xml
echo "Upload /var/tmp/grafana-saml-metadata.xml to your SAML provider"

Create OAuth2 applications

Register OAuth2 applications with Google and GitHub.

Note: For Google OAuth2, visit Google Cloud Console and create OAuth2 credentials with redirect URL http://localhost:3000/login/google. For GitHub, go to GitHub Settings > Developer settings > OAuth Apps and create a new OAuth App with callback URL http://localhost:3000/login/github.

Verify your setup

Test all SSO authentication methods and verify user provisioning works correctly.

sudo systemctl status grafana-server
curl -I http://localhost:3000/login
sudo tail -f /var/log/grafana/grafana.log

Access Grafana at http://localhost:3000 and test each authentication method. Check that users are automatically assigned to correct teams and organizations based on their group memberships.

sudo grafana-cli admin ldap-test
sudo journalctl -u grafana-server -f

Common issues

Symptom Cause Fix
LDAP authentication fails Incorrect bind credentials or search filter Test with sudo grafana-cli admin ldap-test and check bind_dn/bind_password
SAML metadata errors Certificate mismatch or expired certificates Regenerate certificates and update IdP metadata
OAuth2 redirect mismatch Incorrect callback URLs in OAuth2 app configuration Update redirect URLs to match Grafana server URL
Users not assigned to teams Group mapping configuration incorrect Check group_dn values and team synchronization settings
Permission denied on config files Incorrect file ownership or permissions Run sudo chown grafana:grafana /etc/grafana/* and chmod 640

Next steps

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle infrastructure security hardening for businesses that depend on uptime. From initial setup to ongoing operations.