-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for authenticated iframe (with JWT) #326
base: master
Are you sure you want to change the base?
Conversation
PHP is far from my preferred language, I don't use it a long time, so feel free to change the code if you see something wrong. I didn't use IDE, so I don't know if there's some code warning or deprecation. Tested with PHP 8.1, with Icinga DB. JWT is very useful, it is easy to configure on Grafana, and well documented. |
996e36b
to
1863828
Compare
The image renderer from Grafana is very slow and cpu heavy. Iframe is not an option for most cases because it needs anonymous access to Grafana. This commit adds JWT support to secure the Grafana access when using iframe. When a graph is loaded in Icinga web interface, the signed JWT token is sent to Grafana in the request, if JWT is validated graph is displayed, if anything goes wrong with the token validation, Grafana will refuse the access. The library Firebase PHP-JWT is used to create the token. For now, the library is included in the vendor directory. The JWT token uses RSA keys, these keys are generated automatically in /etc when the user saves the configuration with jwt enabled.
1863828
to
5f5cff8
Compare
Forgot to mention, the JWT auth support was introduced in Grafana 8.0.0-beta1 |
This works fine for me. Is it going to be merged? |
'class' => 'autosubmit', | ||
) | ||
); | ||
if ($formData['grafana_jwtEnable']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thorws an error in my setup, better:
if (isset($formData['grafana_jwtEnable']) && $formData['grafana_jwtEnable']) {
?
except this it works perfectly!
The image renderer from Grafana is very slow and cpu heavy. Iframe is not an option for most cases because it needs anonymous access to Grafana. This commit adds JWT support to secure the Grafana access when using iframe.
When a graph is loaded in Icinga web interface, the signed JWT token is sent to Grafana in the request, if JWT is validated graph is displayed, if anything goes wrong with the token validation, Grafana will refuse the access.
The library Firebase PHP-JWT is used to create the token. For now, the library is included in the vendor directory.
The JWT token uses RSA keys, these keys are generated automatically in /etc when the user saves the configuration with jwt enabled.