Grafana Authentication & Roles
Page not available in that version
The current page Grafana Authentication & Roles doesn't exist in version v1.4.1 of the documentation for this product.
Overview
Grafana authentication is delegated entirely to Zitadel via OAuth2/OIDC. Local username/password login is not available to end users. When a user logs into Grafana, they are redirected to Zitadel to authenticate, and their Grafana role is automatically determined by the Zitadel project roles assigned to their account.
The OIDC integration between Grafana and Zitadel is configured automatically at install time — no manual Zitadel application registration is required.
How It Works
During installation, an init container runs before Grafana starts and:
- Authenticates with Zitadel using a machine-account service key.
- Registers a
GrafanaOIDC application in the Zitadel project (or re-uses an existing one if already registered). - Writes the resulting
client_idandclient_secretinto a Kubernetes Secret, which Grafana picks up on startup.
This means the Grafana OIDC application in Zitadel is managed automatically and does not need to be created or modified manually.
Role Mapping
Grafana roles are mapped from Zitadel project roles using the following rule:
| Zitadel Project Role | Grafana Role |
|---|---|
grafana_admin | Admin — full access, can manage users, datasources, and dashboards |
| (any other role, or no role) | Viewer — read-only access to dashboards |
Note: There is no Grafana
Editorrole mapped by default. All authenticated users who are not explicitly grantedgrafana_adminreceive Viewer access. If you need an Editor tier, see Customising the Role Mapping.
The mapping is enforced on every login. If a user’s Zitadel role changes, the change takes effect the next time they log into Grafana.
Prerequisites
- Zitadel is configured and accessible at
https://<manager-host> - At least one Zitadel user account exists (see Next Steps — Create User Accounts)
- Grafana is accessed via the correct DNS hostname (see Accessing Grafana)
Accessing Grafana
Grafana is accessible at:
https://<manager-host>/grafana
Important: Grafana must be accessed using the DNS name specified in the first entry of
global.hosts.managerin your configuration. Accessing Grafana via an IP address or an alternative hostname will cause OAuth2 redirect URI mismatches and CORS errors, preventing login from completing successfully.
To log in:
- Navigate to
https://<manager-host>/grafana - Click “Login with Zitadel”
- Authenticate with your Zitadel account credentials
Granting Admin Access
By default, all Zitadel users who log into Grafana receive Viewer access. To grant a user Admin access, assign them the grafana_admin project role in Zitadel.
Step 1: Ensure the grafana_admin Role Exists
- Log into the Zitadel Console at
https://<manager-host>/ui/console - Navigate to Projects and open the ZITADEL project
- Click the Roles tab
- Check whether a role named
grafana_adminalready exists - If it does not exist, click New Role and create it:
- Key:
grafana_admin - Display Name: Grafana Admin (or any label you prefer)
- Click Save
- Key:
Step 2: Assign the Role to a User
- In the Zitadel Console, navigate to Users and open the user you want to grant admin access to
- Click the Authorizations tab
- Click New Authorization
- Select the ZITADEL project
- Select the
grafana_adminrole - Click Save
The user will have Grafana Admin access the next time they log in.
Revoking Admin Access
To demote a user back to Viewer, remove the grafana_admin authorization from their account:
- In the Zitadel Console, open the user’s Authorizations tab
- Find the
grafana_adminauthorization on the ZITADEL project - Click the delete icon to remove it
The change takes effect on their next Grafana login.
Customising the Role Mapping
The role mapping expression is configured in values.yaml under grafana."grafana.ini".auth.generic_oauth.role_attribute_path. It uses JMESPath syntax evaluated against the OIDC token’s role claims.
The default expression is:
grafana:
"grafana.ini":
auth.generic_oauth:
role_attribute_path: >-
contains(keys("urn:zitadel:iam:org:project:roles"), 'grafana_admin') && 'Admin' || 'Viewer'
Example: Adding an Editor Tier
To map a grafana_editor Zitadel role to Grafana’s Editor role, create the grafana_editor role in Zitadel (following the same steps as above) and extend the expression:
grafana:
"grafana.ini":
auth.generic_oauth:
role_attribute_path: >-
contains(keys("urn:zitadel:iam:org:project:roles"), 'grafana_admin') && 'Admin'
|| contains(keys("urn:zitadel:iam:org:project:roles"), 'grafana_editor') && 'Editor'
|| 'Viewer'
Apply the change using the standard upgrade procedure in the Configuration Guide.
Blocking Unauthenticated Access
By default, role_attribute_strict is set to false, which means any authenticated Zitadel user can log into Grafana as a Viewer even if they have no explicit Grafana role assigned. To restrict Grafana access to only users who have been explicitly granted a role, set this to true:
grafana:
"grafana.ini":
auth.generic_oauth:
role_attribute_strict: true
With role_attribute_strict: true, users who do not match any role in the role_attribute_path expression will be denied access entirely.
Managing Users in Grafana
User accounts in Grafana are created automatically on first login via Zitadel. There is no need to pre-create users in the Grafana UI.
To view and manage users who have logged in:
- Log into Grafana as an Admin
- Navigate to Administration > Users and access > Users
From here you can see each user’s current role, last login time, and authentication provider. Role changes should always be made via Zitadel (as described above) rather than directly in Grafana, as they will be overwritten on the user’s next login.
Break-Glass Admin Access
A local Grafana admin account is available as a break-glass fallback for situations where Zitadel is unavailable. This account is not accessible via the standard login page (which only shows the Zitadel SSO button).
To use the local admin account, navigate directly to:
https://<manager-host>/grafana/login
The default credentials are listed in the Glossary. Change the default password immediately after installation.
Security recommendation: The break-glass account should be used only for emergency access. Do not use it for routine administration.
Troubleshooting
OAuth2 Redirect URI Mismatch / CORS Errors
Grafana is registered in Zitadel with the redirect URI https://<manager-host>/grafana/login/generic_oauth, derived from the first entry of global.hosts.manager. Accessing Grafana via a different hostname or IP address will not match this URI and will cause the login to fail.
Resolution: Always access Grafana via the configured hostname. If the hostname has changed, re-run the helm upgrade to re-register the application with the updated URI.
User Receives Viewer Instead of Admin
The grafana_admin role is not included in the user’s Zitadel token.
Resolution:
- Confirm the
grafana_adminrole exists on the ZITADEL project in the Zitadel Console - Confirm the role is assigned to the user under their Authorizations tab
- Ask the user to log out of Grafana and log back in — role changes are applied on the next login, not the current session
Login Fails with “Role not found” or Access Denied
role_attribute_strict may be set to true and the user has no matching Zitadel role.
Resolution: Either assign the user an appropriate Zitadel project role, or set role_attribute_strict: false in values.yaml to allow all authenticated users Viewer access.
Admin Role Assigned in Zitadel but User Still Gets Viewer
The grafana_admin role is correctly assigned to the user in Zitadel, but Grafana still grants them Viewer access. This indicates that role claims are not being included in the Zitadel userinfo response.
Grafana determines roles by calling the Zitadel userinfo endpoint (/oidc/v1/userinfo) and evaluating the urn:zitadel:iam:org:project:roles claim. Zitadel only includes this claim when the Grafana OIDC application has Access Token Role Assertions enabled. If the claim is absent, the role_attribute_path expression always falls through to 'Viewer'.
To verify and fix:
- Log into the Zitadel Console at
https://<manager-host>/ui/console - Navigate to Projects > ZITADEL > Applications > Grafana
- Open the Token Settings tab
- Ensure Access Token Role Assertions is enabled
- Save the change
The fix takes effect on the user’s next login — no Grafana or Helm changes are required.
Grafana OIDC App Not Registered in Zitadel
If the init container failed during installation, the Grafana OIDC application may not have been created in Zitadel.
Resolution: Check the init container logs for errors:
kubectl logs -l app.kubernetes.io/component=grafana --previous -c zitadel-oauth-setup
Common causes are Zitadel not being ready when the init container ran, or a machine-key permission issue. Re-running the helm upgrade will re-trigger the init container and attempt registration again.
Next Steps
- Grafana Dashboards - Using and customising dashboards
- Alerts & Alarms - Configure alerting and notifications
- Metrics & Monitoring Overview - Return to the monitoring overview