Grafana
Configure Grafana OIDC with Pocket ID
Below URLs are used as placeholders for the Grafana and Pocket ID instances. Replace them with the actual URLs.
- grafana.example.com (The url of your Grafana instance.)
- pocketid.example.com (The url of your Pocket ID instance.)
Pocket ID Setup
- In Pocket ID, create a new OIDC client named
grafana(or any name you prefer). - (Optional) Set a logo for the OIDC client.
- Set the callback URL to:
https://grafana.example.com/login/generic_oauth, or leave blank to autofill on first login. - Copy the
Client ID,Client Secret,Authorization URLandToken URLfor the next steps.
Grafana App Setup
- Login to Grafana as the admin user.
- Go to Administration -> Authentication and select Generic OAuth.
- Enter the values for the fields as given below in the General Settings:
Display Nameas 'Pocket ID' or something similar.Client Idas theClient IDfrom above.Client secretas theClient Secretfrom above.Auth styleas 'Auto Detect'.Scopesas 'openid', 'email' and 'profile'.Auth URLasAuthorization URLfrom above.Token URLasToken URLfrom above.- Leave
API URLandSign out redirect URLas empty. - Leave
Allow sign upandAuto loginas disabled.
- Under User mapping:
- Only set
Email attribute nameas 'email:primary' and leave all other fields as empty. - Only enable
Skip organization role syncand other toggles as disabled.
- Only set
- Nothing to be done under Extra security measures.
- Save the settings.
- Next create a new admin user or update the existing admin user under the Users settings to have the same email address as your user in Pocket-ID. Also set the username to the same email id.
- Logout and test the OAuth based login.
Role Mapping
To use group membership to assign roles automatically:
- Add
groupsto theScopessetting:openid email profile groups - Set the
role attribute pathaccording to the examples. For example:role_attribute_path: contains(groups[*], 'Monitoring Admin') && 'Admin' || contains(groups[*], 'Monitoring') && 'Editor' || 'Viewer'will grant the "Admin" role to anyone with the "Monitoring Admin" group, the "Editor" role to anyone with the "Monitoring" group, and the "Viewer" role to any other logged-in user.
- Logout and back in to update your role.
Common problems
- In case you get locked out of your account before the OAuth setup is completed successfully and need to reset the password refer this link.
- In case login fails with information that the callback url is wrong and you are behind reverse-proxy, you might need to set
root_urlin the grafana.ini to use properly sethttps, for example:https://grafana.example.com/. - In case everything is set as according to the steps described above and you are still getting
Login failed: Sign up is disabled, you might need to setoauth_allow_insecure_email_lookup=truein the[auth]section in the grafana.ini file.