Skip to content

Commit 3209473

Browse files
committed
Merge branch '12886-docs-authentication-section'
2 parents d76dad8 + d6f9eba commit 3209473

File tree

11 files changed

+603
-535
lines changed

11 files changed

+603
-535
lines changed

docs/sources/administration/permissions.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ This admin flag makes a user a `Super Admin`. This means they can access the `Se
5252

5353
### Dashboard & Folder Permissions
5454

55-
> Introduced in Grafana v5.0
56-
5755
{{< docs-imagebox img="/img/docs/v50/folder_permissions.png" max-width="500px" class="docs-image--right" >}}
5856

5957
For dashboards and dashboard folders there is a **Permissions** page that make it possible to

docs/sources/tutorials/authproxy.md renamed to docs/sources/auth/auth-proxy.md

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
+++
2-
title = "Grafana Authproxy"
2+
title = "Auth Proxy"
3+
description = "Grafana Auth Proxy Guide "
4+
keywords = ["grafana", "configuration", "documentation", "proxy"]
35
type = "docs"
4-
keywords = ["grafana", "tutorials", "authproxy"]
6+
aliases = ["/tutorials/authproxy/"]
57
[menu.docs]
6-
parent = "tutorials"
7-
weight = 10
8+
name = "Auth Proxy"
9+
identifier = "auth-proxy"
10+
parent = "authentication"
11+
weight = 2
812
+++
913

10-
# Grafana Authproxy
14+
# Auth Proxy Authentication
1115

12-
AuthProxy allows you to offload the authentication of users to a web server (there are many reasons why you’d want to run a web server in front of a production version of Grafana, especially if it’s exposed to the Internet).
16+
You can configure Grafana to let a http reverse proxy handling authentication. Popular web servers have a very
17+
extensive list of pluggable authentication modules, and any of them can be used with the AuthProxy feature.
18+
Below we detail the configuration options for auth proxy.
1319

14-
Popular web servers have a very extensive list of pluggable authentication modules, and any of them can be used with the AuthProxy feature.
15-
16-
The Grafana AuthProxy feature is very simple in design, but it is this simplicity that makes it so powerful.
17-
18-
## Interacting with Grafana’s AuthProxy via curl
19-
20-
The AuthProxy feature can be configured through the Grafana configuration file with the following options:
21-
22-
```js
20+
```bash
2321
[auth.proxy]
22+
# Defaults to false, but set to true to enable this feature
2423
enabled = true
24+
# HTTP Header name that will contain the username or email
2525
header_name = X-WEBAUTH-USER
26+
# HTTP Header property, defaults to `username` but can also be `email`
2627
header_property = username
28+
# Set to `true` to enable auto sign up of users who do not exist in Grafana DB. Defaults to `true`.
2729
auto_sign_up = true
30+
# If combined with Grafana LDAP integration define sync interval
2831
ldap_sync_ttl = 60
32+
# Limit where auth proxy requests come from by configuring a list of IP addresses.
33+
# This can be used to prevent users spoofing the X-WEBAUTH-USER header.
2934
whitelist =
35+
# Optionally define more headers to sync other user attributes
36+
# Example `headers = Name:X-WEBAUTH-NAME Email:X-WEBAUTH-EMAIL``
37+
headers =
3038
```
3139

32-
* **enabled**: this is to toggle the feature on or off
33-
* **header_name**: this is the HTTP header name that passes the username or email address of the authenticated user to Grafana. Grafana will trust what ever username is contained in this header and automatically log the user in.
34-
* **header_property**: this tells Grafana whether the value in the header_name is a username or an email address. (In Grafana you can log in using your account username or account email)
35-
* **auto_sign_up**: If set to true, Grafana will automatically create user accounts in the Grafana DB if one does not exist. If set to false, users who do not exist in the GrafanaDB won’t be able to log in, even though their username and password are valid.
36-
* **ldap_sync_ttl**: When both auth.proxy and auth.ldap are enabled, user's organisation and role are synchronised from ldap after the http proxy authentication. You can force ldap re-synchronisation after `ldap_sync_ttl` minutes.
37-
* **whitelist**: Comma separated list of trusted authentication proxies IP.
38-
39-
With a fresh install of Grafana, using the above configuration for the authProxy feature, we can send a simple API call to list all users. The only user that will be present is the default “Admin” user that is added the first time Grafana starts up. As you can see all we need to do to authenticate the request is to provide the “X-WEBAUTH-USER” header.
40+
## Interacting with Grafana’s AuthProxy via curl
4041

4142
```bash
4243
curl -H "X-WEBAUTH-USER: admin" http://localhost:3000/api/users
@@ -71,7 +72,8 @@ I’ll demonstrate how to use Apache for authenticating users. In this example w
7172

7273
### Apache BasicAuth
7374

74-
In this example we use Apache as a reverseProxy in front of Grafana. Apache handles the Authentication of users before forwarding requests to the Grafana backend service.
75+
In this example we use Apache as a reverse proxy in front of Grafana. Apache handles the Authentication of users before forwarding requests to the Grafana backend service.
76+
7577

7678
#### Apache configuration
7779

@@ -116,38 +118,7 @@ In this example we use Apache as a reverseProxy in front of Grafana. Apache hand
116118

117119
* The last 3 lines are then just standard reverse proxy configuration to direct all authenticated requests to our Grafana server running on port 3000.
118120

119-
#### Grafana configuration
120-
121-
```bash
122-
############# Users ################
123-
[users]
124-
# disable user signup / registration
125-
allow_sign_up = false
126-
127-
# Set to true to automatically assign new users to the default organization (id 1)
128-
auto_assign_org = true
129-
130-
# Default role new users will be automatically assigned (if auto_assign_org above is set to true)
131-
auto_assign_org_role = Editor
132-
133-
134-
############ Auth Proxy ########
135-
[auth.proxy]
136-
enabled = true
137-
138-
# the Header name that contains the authenticated user.
139-
header_name = X-WEBAUTH-USER
140-
141-
# does the user authenticate against the proxy using a 'username' or an 'email'
142-
header_property = username
143-
144-
# automatically add the user to the system if they don't already exist.
145-
auto_sign_up = true
146-
```
147-
148-
#### Full walk through using Docker.
149-
150-
##### Grafana Container
121+
## Full walk through using Docker.
151122

152123
For this example, we use the official Grafana docker image available at [Docker Hub](https://hub.docker.com/r/grafana/grafana/)
153124

@@ -166,7 +137,8 @@ header_property = username
166137
auto_sign_up = true
167138
```
168139

169-
* Launch the Grafana container, using our custom grafana.ini to replace `/etc/grafana/grafana.ini`. We don't expose any ports for this container as it will only be connected to by our Apache container.
140+
Launch the Grafana container, using our custom grafana.ini to replace `/etc/grafana/grafana.ini`. We don't expose
141+
any ports for this container as it will only be connected to by our Apache container.
170142

171143
```bash
172144
docker run -i -v $(pwd)/grafana.ini:/etc/grafana/grafana.ini --name grafana grafana/grafana

docs/sources/auth/generic-oauth.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
+++
2+
title = "OAuth authentication"
3+
description = "Grafana OAuthentication Guide "
4+
keywords = ["grafana", "configuration", "documentation", "oauth"]
5+
type = "docs"
6+
[menu.docs]
7+
name = "Generic OAuth2"
8+
identifier = "generic_oauth"
9+
parent = "authentication"
10+
weight = 3
11+
+++
12+
13+
# Generic OAuth Authentication
14+
15+
You can configure many different oauth2 authentication services with Grafana using the generic oauth2 feature. Below you
16+
can find examples using Okta, BitBucket, OneLogin and Azure.
17+
18+
This callback URL must match the full HTTP address that you use in your browser to access Grafana, but with the prefix path of `/login/generic_oauth`.
19+
20+
Example config:
21+
22+
```bash
23+
[auth.generic_oauth]
24+
enabled = true
25+
client_id = YOUR_APP_CLIENT_ID
26+
client_secret = YOUR_APP_CLIENT_SECRET
27+
scopes =
28+
auth_url =
29+
token_url =
30+
api_url =
31+
allowed_domains = mycompany.com mycompany.org
32+
allow_sign_up = true
33+
```
34+
35+
Set api_url to the resource that returns [OpenID UserInfo](https://connect2id.com/products/server/docs/api/userinfo) compatible information.
36+
37+
## Set up OAuth2 with Okta
38+
39+
First set up Grafana as an OpenId client "webapplication" in Okta. Then set the Base URIs to `https://<grafana domain>/` and set the Login redirect URIs to `https://<grafana domain>/login/generic_oauth`.
40+
41+
Finally set up the generic oauth module like this:
42+
```bash
43+
[auth.generic_oauth]
44+
name = Okta
45+
enabled = true
46+
scopes = openid profile email
47+
client_id = <okta application Client ID>
48+
client_secret = <okta application Client Secret>
49+
auth_url = https://<okta domain>/oauth2/v1/authorize
50+
token_url = https://<okta domain>/oauth2/v1/token
51+
api_url = https://<okta domain>/oauth2/v1/userinfo
52+
```
53+
54+
## Set up OAuth2 with Bitbucket
55+
56+
```bash
57+
[auth.generic_oauth]
58+
name = BitBucket
59+
enabled = true
60+
allow_sign_up = true
61+
client_id = <client id>
62+
client_secret = <client secret>
63+
scopes = account email
64+
auth_url = https://bitbucket.org/site/oauth2/authorize
65+
token_url = https://bitbucket.org/site/oauth2/access_token
66+
api_url = https://api.bitbucket.org/2.0/user
67+
team_ids =
68+
allowed_organizations =
69+
```
70+
71+
## Set up OAuth2 with OneLogin
72+
73+
1. Create a new Custom Connector with the following settings:
74+
- Name: Grafana
75+
- Sign On Method: OpenID Connect
76+
- Redirect URI: `https://<grafana domain>/login/generic_oauth`
77+
- Signing Algorithm: RS256
78+
- Login URL: `https://<grafana domain>/login/generic_oauth`
79+
80+
then:
81+
2. Add an App to the Grafana Connector:
82+
- Display Name: Grafana
83+
84+
then:
85+
3. Under the SSO tab on the Grafana App details page you'll find the Client ID and Client Secret.
86+
87+
Your OneLogin Domain will match the url you use to access OneLogin.
88+
89+
Configure Grafana as follows:
90+
91+
```bash
92+
[auth.generic_oauth]
93+
name = OneLogin
94+
enabled = true
95+
allow_sign_up = true
96+
client_id = <client id>
97+
client_secret = <client secret>
98+
scopes = openid email name
99+
auth_url = https://<onelogin domain>.onelogin.com/oidc/auth
100+
token_url = https://<onelogin domain>.onelogin.com/oidc/token
101+
api_url = https://<onelogin domain>.onelogin.com/oidc/me
102+
team_ids =
103+
allowed_organizations =
104+
```
105+
106+
### Set up OAuth2 with Auth0
107+
108+
1. Create a new Client in Auth0
109+
- Name: Grafana
110+
- Type: Regular Web Application
111+
112+
2. Go to the Settings tab and set:
113+
- Allowed Callback URLs: `https://<grafana domain>/login/generic_oauth`
114+
115+
3. Click Save Changes, then use the values at the top of the page to configure Grafana:
116+
117+
```bash
118+
[auth.generic_oauth]
119+
enabled = true
120+
allow_sign_up = true
121+
team_ids =
122+
allowed_organizations =
123+
name = Auth0
124+
client_id = <client id>
125+
client_secret = <client secret>
126+
scopes = openid profile email
127+
auth_url = https://<domain>/authorize
128+
token_url = https://<domain>/oauth/token
129+
api_url = https://<domain>/userinfo
130+
```
131+
132+
### Set up OAuth2 with Azure Active Directory
133+
134+
1. Log in to portal.azure.com and click "Azure Active Directory" in the side menu, then click the "Properties" sub-menu item.
135+
136+
2. Copy the "Directory ID", this is needed for setting URLs later
137+
138+
3. Click "App Registrations" and add a new application registration:
139+
- Name: Grafana
140+
- Application type: Web app / API
141+
- Sign-on URL: `https://<grafana domain>/login/generic_oauth`
142+
143+
4. Click the name of the new application to open the application details page.
144+
145+
5. Note down the "Application ID", this will be the OAuth client id.
146+
147+
6. Click "Settings", then click "Keys" and add a new entry under Passwords
148+
- Key Description: Grafana OAuth
149+
- Duration: Never Expires
150+
151+
7. Click Save then copy the key value, this will be the OAuth client secret.
152+
153+
8. Configure Grafana as follows:
154+
155+
```bash
156+
[auth.generic_oauth]
157+
name = Azure AD
158+
enabled = true
159+
allow_sign_up = true
160+
client_id = <application id>
161+
client_secret = <key value>
162+
scopes = openid email name
163+
auth_url = https://login.microsoftonline.com/<directory id>/oauth2/authorize
164+
token_url = https://login.microsoftonline.com/<directory id>/oauth2/token
165+
api_url =
166+
team_ids =
167+
allowed_organizations =
168+
```
169+
170+
<hr>
171+
172+

0 commit comments

Comments
 (0)