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
Google OAuth
Azure AD OAuth
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:
Auth Proxy
Authenticate users via a reverse proxy.JWT Authentication
Anonymous Access
Allow unauthenticated access to Grafana.User Management
User Registration
Authentication Settings
Security Settings
Best Practices
- Use OAuth/SAML for production - Integrate with your organization’s identity provider
- Enable HTTPS - Always use TLS for authentication in production
- Disable unnecessary auth methods - Only enable authentication methods you need
- Use strong passwords - Enable password policy for basic auth
- Restrict sign-up - Disable
allow_sign_upin production - Configure role mapping - Map external groups to Grafana roles
- Enable brute force protection - Protect against login attacks
- Use refresh tokens - Enable
use_refresh_tokenfor OAuth providers - Store secrets securely - Use environment variables for OAuth secrets
- Test authentication - Verify auth configuration before deploying to production
Troubleshooting
OAuth redirect URI mismatch:- Verify
root_urlin[server]section matches OAuth redirect URI - Check OAuth provider configuration
- Test LDAP connection with
ldapsearch - Verify bind credentials and search filters
- Check LDAP server logs
- Check Grafana logs for authentication errors
- Verify user exists and has correct role
- Test with admin user to isolate issue
- Enable
use_refresh_tokento automatically refresh tokens - Check token expiration settings in OAuth provider