In my web application, I want to provide the ability to pass authenticated users from my dashboard across to Grafana.
Once a user logged in my dashboard using credentials, a link to Grafana Dashboard will be displayed on my application. When user clicks that link, he/she will be redirected to Grafana page and automatically log in without displaying the Grafana login page. I don't want my users must encounter a second login screen, where they will be confused as to what username/password to enter.
I've followed Automatic login to grafana from web application, Auto login to grafana dashboard, Auto login to grafana from Web application using credentials or token and Automatic login by token url, but no luck. I couldn't find appropriate & clean solution.
I'm using Grafana v6.2.5 installed on Ubuntu Server 18.04.
How can I implement it? Any help would be appreciated.
Server Details: Ubuntu Server 18.04, Apache 2.4.29
After some digging, I've found a workaround using Grafana's Generic OAuth Authentication.
Step 1: Create files with the following code in it.
GrafanaOAuth.php
:oauth/auth.php
:oauth/token.php
:oauth/user.php
:custom.js
:Step 2: Edit Grafana configuration file which is located at
/etc/grafana/grafana.ini
on Ubuntu / Debian,/usr/local/etc/grafana/grafana.ini
on MAC,<GRAFANA_PROJECT_FOLDER>/conf/custom.ini
on Windows.Uncomment these lines and enter your
client_id
,client_secret
,auth_url
,token_url
,api_url
:Like so:
Step 3: Place
custom.js
in/usr/share/grafana/public/build/index.html
file (Ubuntu / Debian) at the bottom of<body>
tag.Step 4: Restart Grafana server.
sudo service grafana-server restart
(Ubuntu / Debian)brew services restart grafana
(MAC)For the example and detailed explanation, have a look at my Github repo.