Skip to main content
Grafana supports multiple authentication methods including built-in authentication, OAuth providers, LDAP, SAML, and more. This guide covers configuring authentication for your Grafana deployment.

Authentication Methods

Grafana supports these authentication methods:
  • Basic Authentication - Built-in username/password authentication
  • OAuth 2.0 - GitHub, Google, GitLab, Azure AD, Okta, Generic OAuth
  • LDAP - Active Directory and other LDAP servers
  • SAML - Enterprise SSO (Grafana Enterprise)
  • Auth Proxy - Reverse proxy authentication
  • JWT - JSON Web Token authentication
  • Anonymous Access - Allow unauthenticated access

Basic Authentication

Built-in username and password authentication.

Configuration

Environment Variables

Admin User

Configure the default admin user created on first startup:

OAuth Authentication

Integrate with OAuth 2.0 providers for single sign-on.

GitHub OAuth

Environment Variables:

Google OAuth

Environment Variables:

Azure AD OAuth

Environment Variables:

GitLab OAuth

Okta OAuth

Generic OAuth

Configure any OAuth 2.0 compatible provider:

LDAP Authentication

Integrate with LDAP and Active Directory.

Configuration

LDAP Configuration File

Create /etc/grafana/ldap.toml:
Environment Variables:

Auth Proxy

Authenticate users via a reverse proxy.
Environment Variables:

JWT Authentication

Anonymous Access

Allow unauthenticated access to Grafana.
Environment Variables:

User Management

User Registration

Authentication Settings

Security Settings

Best Practices

  1. Use OAuth/SAML for production - Integrate with your organization’s identity provider
  2. Enable HTTPS - Always use TLS for authentication in production
  3. Disable unnecessary auth methods - Only enable authentication methods you need
  4. Use strong passwords - Enable password policy for basic auth
  5. Restrict sign-up - Disable allow_sign_up in production
  6. Configure role mapping - Map external groups to Grafana roles
  7. Enable brute force protection - Protect against login attacks
  8. Use refresh tokens - Enable use_refresh_token for OAuth providers
  9. Store secrets securely - Use environment variables for OAuth secrets
  10. Test authentication - Verify auth configuration before deploying to production

Troubleshooting

OAuth redirect URI mismatch:
  • Verify root_url in [server] section matches OAuth redirect URI
  • Check OAuth provider configuration
LDAP authentication fails:
  • Test LDAP connection with ldapsearch
  • Verify bind credentials and search filters
  • Check LDAP server logs
Users can’t log in:
  • Check Grafana logs for authentication errors
  • Verify user exists and has correct role
  • Test with admin user to isolate issue
OAuth token expired:
  • Enable use_refresh_token to automatically refresh tokens
  • Check token expiration settings in OAuth provider