Add JWT url auth documentation (#54040)

* add jwt auth docs

* add appropriate warnings to docs

* remove unimplemented login_token assumptions

* Update conf/sample.ini
This commit is contained in:
Jo 2022-09-05 08:46:50 +01:00 committed by GitHub
parent 78978048c3
commit 4952b7f22d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View File

@ -598,6 +598,7 @@
;expected_claims = {"aud": ["foo", "bar"]}
;key_file = /path/to/key/file
;auto_sign_up = false
;url_login = false
#################################### Auth LDAP ##########################
[auth.ldap]

View File

@ -15,7 +15,6 @@ signout_redirect_url = http://env.grafana.local:8088/oauth2/sign_out
[auth.jwt]
enabled = true
enable_login_token = true
header_name = X-Forwarded-Access-Token
username_claim = login
email_claim = email

View File

@ -15,6 +15,10 @@ You can configure Grafana to accept a JWT token provided in the HTTP header. The
- JSON Web Key Set (JWKS) in a local file
- JWKS provided by the configured JWKS endpoint
This method of authentication is useful for integrating with other systems that
use JWKS but can't directly integrate with Grafana or if you want to use pass-through
authentication in an app embedding Grafana.
## Enable JWT
To use JWT authentication:
@ -53,6 +57,46 @@ email_claim = sub
If `auto_sign_up` is enabled, then the `sub` claim is used as the "external Auth ID". The `name` claim is used as the user's full name if it is present.
## Iframe Embedding
If you want to embed Grafana in an iframe while maintaning user identity and role checks,
you can use JWT authentication to authenticate the iframe.
> **Note**: for scenarios where verifying viewer identity is not required,
> [public dashboards]({{< relref "../../../dashboards/dashboard-public" >}}) embedding should be used.
In this scenario, you will need to configure Grafana to accept a JWT
provided in the HTTP header and a reverse proxy should rewrite requests to the
Grafana instance to include the JWT in the request's headers.
> **Note**: for embedding to work `allow_embedding` must be enabled in the [security section]({{< relref "../../configure-grafana#allow_embedding" >}}).
In a scenario where it is not possible to rewrite the request headers you
can use URL login instead.
### URL login
`url_login` allows grafana to search for a JWT in the URL query parameter
`auth_token` and use it as the authentication token.
> **Warning**: this can lead to JWTs being exposed in logs and possible session hijacking if the server is not
> using HTTP over TLS.
```ini
# [auth.jwt]
# ...
url_login = true # enable JWT authentication in the URL
```
An example of an URL for accessing grafana with JWT URL authentication is:
```
http://env.grafana.local/d/RciOKLR4z/board-identifier?orgId=1&kiosk&auth_token=eyJhbxxxxxxxxxxxxx
```
A sample repository using this authentication method is available
at [grafana-iframe-oauth-sample](https://github.com/grafana/grafana-iframe-oauth-sample).
## Signature verification
JSON web token integrity needs to be verified so cryptographic signature is used for this purpose. So we expect that every token must be signed with some known cryptographic key.