I have a React + DRF web app that has JWT authentication, in which I use djangorestframework-simplejwt.
I store access and refresh tokens in the localStorage. Is it possible to use these tokens to authenticate in Grafana? If yes, how can I do that? When I navigate to /grafana (with nginx help), I would like to see that my user in my app to be logged in to the Grafana, by creating the user for Grafana if necessary.
2
Answers
Let me explain all of the details for those who seek a solution to the problem of using common JWT for their app and Grafana. You can skip the beginning if you only care about Grafana side only:
React side:
Django REST Framework side (djangorestframework-simplejwt):
jwcrypto
. I setSIGNING_KEY
with the contents of the private key .pem and setVERIFYING_KEY
with the contents of the public key .pem.Grafana side:
To make sure that this is working, you need to create users with same username for the Grafana. Otherwise you will get
Invalid JWT
response.auto_sign_up
setting is not working for the JWT authentication yet.Then I added these configurations for Grafana container.
header_name
can be any string and but you need to use it in nginx side too:Nginx side:
It is not clear what is "JWT authentication" and how JWT was created. I guess it is from Open ID Connect authentication, so then nothing is stopping you to use Grafana OIDC auth with the same OIDC identuty provider, to have seamless user single sign on experience.