mirror of https://github.com/grafana/grafana
prometheushacktoberfestmetricsmonitoringalertinggrafanagoinfluxdbmysqlpostgresanalyticsdata-visualizationdashboardbusiness-intelligenceelasticsearch
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
351 lines
13 KiB
351 lines
13 KiB
|
4 years ago
|
---
|
||
|
|
aliases:
|
||
|
|
- /docs/grafana/latest/auth/ldap/
|
||
|
|
- /docs/grafana/latest/installation/ldap/
|
||
|
4 years ago
|
- /docs/grafana/latest/setup-grafana/configure-security/configure-authentication/ldap/
|
||
|
|
description: Grafana LDAP Authentication Guide
|
||
|
|
title: Configure LDAP Authentication
|
||
|
|
weight: 800
|
||
|
4 years ago
|
---
|
||
|
11 years ago
|
|
||
|
4 years ago
|
# Configure LDAP authentication
|
||
|
7 years ago
|
|
||
|
|
The LDAP integration in Grafana allows your Grafana users to login with their LDAP credentials. You can also specify mappings between LDAP
|
||
|
7 years ago
|
group memberships and Grafana Organization user roles.
|
||
|
|
|
||
|
4 years ago
|
> [Enhanced LDAP authentication]({{< relref "enhanced_ldap/" >}}) is available in [Grafana Cloud Advanced](https://grafana.com/docs/grafana-cloud/) and in [Grafana Enterprise]({{< relref "../../../enterprise/" >}}).
|
||
|
6 years ago
|
|
||
|
4 years ago
|
> Refer to [Role-based access control]({{< relref "../../../enterprise/access-control/" >}}) in Grafana Enterprise to understand how you can control access with role-based permissions.
|
||
|
4 years ago
|
|
||
|
7 years ago
|
## Supported LDAP Servers
|
||
|
|
|
||
|
|
Grafana uses a [third-party LDAP library](https://github.com/go-ldap/ldap) under the hood that supports basic LDAP v3 functionality.
|
||
|
|
This means that you should be able to configure LDAP integration using any compliant LDAPv3 server, for example [OpenLDAP](#openldap) or
|
||
|
|
[Active Directory](#active-directory) among [others](https://en.wikipedia.org/wiki/Directory_service#LDAP_implementations).
|
||
|
7 years ago
|
|
||
|
7 years ago
|
## Enable LDAP
|
||
|
7 years ago
|
|
||
|
4 years ago
|
In order to use LDAP integration you'll first need to enable LDAP in the [main config file]({{< relref "../../configure-grafana/" >}}) as well as specify the path to the LDAP
|
||
|
11 years ago
|
specific configuration file (default: `/etc/grafana/ldap.toml`).
|
||
|
|
|
||
|
7 years ago
|
```bash
|
||
|
|
[auth.ldap]
|
||
|
|
# Set to `true` to enable LDAP integration (default: `false`)
|
||
|
|
enabled = true
|
||
|
7 years ago
|
|
||
|
7 years ago
|
# Path to the LDAP specific configuration file (default: `/etc/grafana/ldap.toml`)
|
||
|
7 years ago
|
config_file = /etc/grafana/ldap.toml
|
||
|
|
|
||
|
6 years ago
|
# Allow sign up should almost always be true (default) to allow new Grafana users to be created (if LDAP authentication is ok). If set to
|
||
|
|
# false only pre-existing Grafana users will be able to login (if LDAP authentication is ok).
|
||
|
7 years ago
|
allow_sign_up = true
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
## Grafana LDAP Configuration
|
||
|
11 years ago
|
|
||
|
7 years ago
|
Depending on which LDAP server you're using and how that's configured your Grafana LDAP configuration may vary.
|
||
|
|
See [configuration examples](#configuration-examples) for more information.
|
||
|
11 years ago
|
|
||
|
7 years ago
|
**LDAP specific configuration file (ldap.toml) example:**
|
||
|
4 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
11 years ago
|
[[servers]]
|
||
|
10 years ago
|
# Ldap server host (specify multiple hosts space separated)
|
||
|
11 years ago
|
host = "127.0.0.1"
|
||
|
10 years ago
|
# Default port is 389 or 636 if use_ssl = true
|
||
|
11 years ago
|
port = 389
|
||
|
5 years ago
|
# Set to true if LDAP server should use an encrypted TLS connection (either with STARTTLS or LDAPS)
|
||
|
11 years ago
|
use_ssl = false
|
||
|
5 years ago
|
# If set to true, use LDAP with STARTTLS instead of LDAPS
|
||
|
9 years ago
|
start_tls = false
|
||
|
6 years ago
|
# set to true if you want to skip SSL cert validation
|
||
|
11 years ago
|
ssl_skip_verify = false
|
||
|
10 years ago
|
# set to the path to your root CA certificate or leave unset to use system defaults
|
||
|
9 years ago
|
# root_ca_cert = "/path/to/certificate.crt"
|
||
|
7 years ago
|
# Authentication against LDAP servers requiring client certificates
|
||
|
|
# client_cert = "/path/to/client.crt"
|
||
|
|
# client_key = "/path/to/client.key"
|
||
|
11 years ago
|
|
||
|
|
# Search user bind dn
|
||
|
|
bind_dn = "cn=admin,dc=grafana,dc=org"
|
||
|
|
# Search user bind password
|
||
|
8 years ago
|
# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
|
||
|
4 years ago
|
bind_password = "grafana"
|
||
|
11 years ago
|
|
||
|
10 years ago
|
# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
|
||
|
7 years ago
|
# Allow login from email or username, example "(|(sAMAccountName=%s)(userPrincipalName=%s))"
|
||
|
11 years ago
|
search_filter = "(cn=%s)"
|
||
|
10 years ago
|
|
||
|
11 years ago
|
# An array of base dns to search through
|
||
|
|
search_base_dns = ["dc=grafana,dc=org"]
|
||
|
|
|
||
|
10 years ago
|
# group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
|
||
|
7 years ago
|
# group_search_filter_user_attribute = "distinguishedName"
|
||
|
10 years ago
|
# group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
|
||
|
|
|
||
|
6 years ago
|
# Specify names of the LDAP attributes your LDAP uses
|
||
|
11 years ago
|
[servers.attributes]
|
||
|
|
member_of = "memberOf"
|
||
|
|
email = "email"
|
||
|
|
```
|
||
|
|
|
||
|
6 years ago
|
### Using environment variables
|
||
|
|
|
||
|
5 years ago
|
You can interpolate variables in the TOML configuration from environment variables. For instance, you could externalize your `bind_password` that way:
|
||
|
6 years ago
|
|
||
|
|
```bash
|
||
|
|
bind_password = "${LDAP_ADMIN_PASSWORD}"
|
||
|
|
```
|
||
|
|
|
||
|
6 years ago
|
## LDAP Debug View
|
||
|
|
|
||
|
|
> Only available in Grafana v6.4+
|
||
|
|
|
||
|
|
Grafana has an LDAP debug view built-in which allows you to test your LDAP configuration directly within Grafana. At the moment of writing, only Grafana admins can use the LDAP debug view.
|
||
|
5 years ago
|
|
||
|
6 years ago
|
Within this view, you'll be able to see which LDAP servers are currently reachable and test your current configuration.
|
||
|
|
|
||
|
5 years ago
|
{{< figure src="/static/img/docs/ldap_debug.png" class="docs-image--no-shadow" max-width="600px" >}}
|
||
|
6 years ago
|
|
||
|
|
To use the debug view:
|
||
|
|
|
||
|
4 years ago
|
1. Type the username of a user that exists within any of your LDAP server(s)
|
||
|
|
1. Then, press "Run"
|
||
|
|
1. If the user is found within any of your LDAP instances, the mapping information is displayed
|
||
|
6 years ago
|
|
||
|
5 years ago
|
{{< figure src="/static/img/docs/ldap_debug_mapping_testing.png" class="docs-image--no-shadow" max-width="600px" >}}
|
||
|
6 years ago
|
|
||
|
7 years ago
|
### Bind
|
||
|
|
|
||
|
6 years ago
|
#### Bind and Bind Password
|
||
|
11 years ago
|
|
||
|
11 years ago
|
By default the configuration expects you to specify a bind DN and bind password. This should be a read only user that can perform LDAP searches.
|
||
|
6 years ago
|
When the user DN is found a second bind is performed with the user provided username and password (in the normal Grafana login form).
|
||
|
11 years ago
|
|
||
|
8 years ago
|
```bash
|
||
|
11 years ago
|
bind_dn = "cn=admin,dc=grafana,dc=org"
|
||
|
|
bind_password = "grafana"
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
#### Single Bind Example
|
||
|
11 years ago
|
|
||
|
11 years ago
|
If you can provide a single bind expression that matches all possible users, you can skip the second bind and bind against the user DN directly.
|
||
|
11 years ago
|
This allows you to not specify a bind_password in the configuration file.
|
||
|
|
|
||
|
8 years ago
|
```bash
|
||
|
11 years ago
|
bind_dn = "cn=%s,o=users,dc=grafana,dc=org"
|
||
|
|
```
|
||
|
|
|
||
|
11 years ago
|
In this case you skip providing a `bind_password` and instead provide a `bind_dn` value with a `%s` somewhere. This will be replaced with the username entered in on the Grafana login page.
|
||
|
10 years ago
|
The search filter and search bases settings are still needed to perform the LDAP search to retrieve the other LDAP information (like LDAP groups and email).
|
||
|
11 years ago
|
|
||
|
7 years ago
|
### POSIX schema
|
||
|
4 years ago
|
|
||
|
6 years ago
|
If your LDAP server does not support the memberOf attribute add these options:
|
||
|
10 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
10 years ago
|
## Group search filter, to retrieve the groups of which the user is a member (only set if memberOf attribute is not available)
|
||
|
|
group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
|
||
|
|
## An array of the base DNs to search through for groups. Typically uses ou=groups
|
||
|
|
group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
|
||
|
7 years ago
|
## the %s in the search filter will be replaced with the attribute defined below
|
||
|
|
group_search_filter_user_attribute = "uid"
|
||
|
10 years ago
|
```
|
||
|
|
|
||
|
7 years ago
|
### Group Mappings
|
||
|
10 years ago
|
|
||
|
4 years ago
|
In `[[servers.group_mappings]]` you can map an LDAP group to a Grafana organization and role. These will be synced every time the user logs in, with LDAP being
|
||
|
7 years ago
|
the authoritative source. So, if you change a user's role in the Grafana Org. Users page, this change will be reset the next time the user logs in. If you
|
||
|
|
change the LDAP groups of a user, the change will take effect the next time the user logs in.
|
||
|
11 years ago
|
|
||
|
5 years ago
|
The first group mapping that an LDAP user is matched to will be used for the sync. If you have LDAP users that fit multiple mappings, the topmost mapping in the TOML configuration will be used.
|
||
|
10 years ago
|
|
||
|
7 years ago
|
**LDAP specific configuration file (ldap.toml) example:**
|
||
|
4 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
|
[[servers]]
|
||
|
|
# other settings omitted for clarity
|
||
|
|
|
||
|
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "cn=superadmins,dc=grafana,dc=org"
|
||
|
|
org_role = "Admin"
|
||
|
|
grafana_admin = true # Available in Grafana v5.3 and above
|
||
|
|
|
||
|
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "cn=admins,dc=grafana,dc=org"
|
||
|
|
org_role = "Admin"
|
||
|
8 years ago
|
|
||
|
7 years ago
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "cn=users,dc=grafana,dc=org"
|
||
|
|
org_role = "Editor"
|
||
|
11 years ago
|
|
||
|
7 years ago
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "*"
|
||
|
|
org_role = "Viewer"
|
||
|
|
```
|
||
|
|
|
||
|
4 years ago
|
| Setting | Required | Description | Default |
|
||
|
|
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- |
|
||
|
|
| `group_dn` | Yes | LDAP distinguished name (DN) of LDAP group. If you want to match all (or no LDAP groups) then you can use wildcard (`"*"`) |
|
||
|
|
| `org_role` | Yes | Assign users of `group_dn` the organization role `"Admin"`, `"Editor"` or `"Viewer"` |
|
||
|
|
| `org_id` | No | The Grafana organization database id. Setting this allows for multiple group_dn's to be assigned to the same `org_role` provided the `org_id` differs | `1` (default org id) |
|
||
|
|
| `grafana_admin` | No | When `true` makes user of `group_dn` Grafana server admin. A Grafana server admin has admin access over all organizations and users. Available in Grafana v5.3 and above | `false` |
|
||
|
7 years ago
|
|
||
|
|
### Nested/recursive group membership
|
||
|
|
|
||
|
|
Users with nested/recursive group membership must have an LDAP server that supports `LDAP_MATCHING_RULE_IN_CHAIN`
|
||
|
|
and configure `group_search_filter` in a way that it returns the groups the submitted username is a member of.
|
||
|
|
|
||
|
6 years ago
|
To configure `group_search_filter`:
|
||
|
4 years ago
|
|
||
|
5 years ago
|
- You can set `group_search_base_dns` to specify where the matching groups are defined.
|
||
|
|
- If you do not use `group_search_base_dns`, then the previously defined `search_base_dns` is used.
|
||
|
6 years ago
|
|
||
|
7 years ago
|
**Active Directory example:**
|
||
|
|
|
||
|
|
Active Directory groups store the Distinguished Names (DNs) of members, so your filter will need to know the DN for the user based only on the submitted username.
|
||
|
6 years ago
|
Multiple DN templates can be searched by combining filters with the LDAP OR-operator. Two examples:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
group_search_filter = "(member:1.2.840.113556.1.4.1941:=%s)"
|
||
|
|
group_search_base_dns = ["DC=mycorp,DC=mytld"]
|
||
|
|
group_search_filter_user_attribute = "dn"
|
||
|
|
```
|
||
|
7 years ago
|
|
||
|
|
```bash
|
||
|
|
group_search_filter = "(member:1.2.840.113556.1.4.1941:=CN=%s,[user container/OU])"
|
||
|
|
group_search_filter = "(|(member:1.2.840.113556.1.4.1941:=CN=%s,[user container/OU])(member:1.2.840.113556.1.4.1941:=CN=%s,[another user container/OU]))"
|
||
|
7 years ago
|
group_search_filter_user_attribute = "cn"
|
||
|
7 years ago
|
```
|
||
|
6 years ago
|
|
||
|
7 years ago
|
For more information on AD searches see [Microsoft's Search Filter Syntax](https://docs.microsoft.com/en-us/windows/desktop/adsi/search-filter-syntax) documentation.
|
||
|
10 years ago
|
|
||
|
7 years ago
|
For troubleshooting, by changing `member_of` in `[servers.attributes]` to "dn" it will show you more accurate group memberships when [debug is enabled](#troubleshooting).
|
||
|
7 years ago
|
|
||
|
|
## Configuration examples
|
||
|
|
|
||
|
|
### OpenLDAP
|
||
|
|
|
||
|
|
[OpenLDAP](http://www.openldap.org/) is an open source directory service.
|
||
|
|
|
||
|
|
**LDAP specific configuration file (ldap.toml):**
|
||
|
4 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
|
[[servers]]
|
||
|
|
host = "127.0.0.1"
|
||
|
|
port = 389
|
||
|
|
use_ssl = false
|
||
|
|
start_tls = false
|
||
|
|
ssl_skip_verify = false
|
||
|
|
bind_dn = "cn=admin,dc=grafana,dc=org"
|
||
|
4 years ago
|
bind_password = "grafana"
|
||
|
7 years ago
|
search_filter = "(cn=%s)"
|
||
|
|
search_base_dns = ["dc=grafana,dc=org"]
|
||
|
|
|
||
|
|
[servers.attributes]
|
||
|
|
member_of = "memberOf"
|
||
|
|
email = "email"
|
||
|
|
|
||
|
|
# [[servers.group_mappings]] omitted for clarity
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
### Multiple LDAP servers
|
||
|
|
|
||
|
|
Grafana does support receiving information from multiple LDAP servers.
|
||
|
|
|
||
|
|
**LDAP specific configuration file (ldap.toml):**
|
||
|
4 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
|
# --- First LDAP Server ---
|
||
|
|
|
||
|
|
[[servers]]
|
||
|
|
host = "10.0.0.1"
|
||
|
|
port = 389
|
||
|
|
use_ssl = false
|
||
|
|
start_tls = false
|
||
|
|
ssl_skip_verify = false
|
||
|
|
bind_dn = "cn=admin,dc=grafana,dc=org"
|
||
|
4 years ago
|
bind_password = "grafana"
|
||
|
7 years ago
|
search_filter = "(cn=%s)"
|
||
|
|
search_base_dns = ["ou=users,dc=grafana,dc=org"]
|
||
|
|
|
||
|
|
[servers.attributes]
|
||
|
|
member_of = "memberOf"
|
||
|
|
email = "email"
|
||
|
|
|
||
|
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "cn=admins,ou=groups,dc=grafana,dc=org"
|
||
|
|
org_role = "Admin"
|
||
|
|
grafana_admin = true
|
||
|
|
|
||
|
|
# --- Second LDAP Server ---
|
||
|
|
|
||
|
|
[[servers]]
|
||
|
|
host = "10.0.0.2"
|
||
|
|
port = 389
|
||
|
|
use_ssl = false
|
||
|
|
start_tls = false
|
||
|
|
ssl_skip_verify = false
|
||
|
|
|
||
|
|
bind_dn = "cn=admin,dc=grafana,dc=org"
|
||
|
4 years ago
|
bind_password = "grafana"
|
||
|
7 years ago
|
search_filter = "(cn=%s)"
|
||
|
|
search_base_dns = ["ou=users,dc=grafana,dc=org"]
|
||
|
|
|
||
|
|
[servers.attributes]
|
||
|
|
member_of = "memberOf"
|
||
|
|
email = "email"
|
||
|
|
|
||
|
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "cn=editors,ou=groups,dc=grafana,dc=org"
|
||
|
|
org_role = "Editor"
|
||
|
|
|
||
|
|
[[servers.group_mappings]]
|
||
|
|
group_dn = "*"
|
||
|
|
org_role = "Viewer"
|
||
|
|
```
|
||
|
|
|
||
|
7 years ago
|
### Active Directory
|
||
|
|
|
||
|
4 years ago
|
[Active Directory](<https://technet.microsoft.com/en-us/library/hh831484(v=ws.11).aspx>) is a directory service which is commonly used in Windows environments.
|
||
|
7 years ago
|
|
||
|
|
Assuming the following Active Directory server setup:
|
||
|
|
|
||
|
5 years ago
|
- IP address: `10.0.0.1`
|
||
|
|
- Domain: `CORP`
|
||
|
|
- DNS name: `corp.local`
|
||
|
7 years ago
|
|
||
|
|
**LDAP specific configuration file (ldap.toml):**
|
||
|
4 years ago
|
|
||
|
7 years ago
|
```bash
|
||
|
|
[[servers]]
|
||
|
|
host = "10.0.0.1"
|
||
|
|
port = 3269
|
||
|
|
use_ssl = true
|
||
|
|
start_tls = false
|
||
|
|
ssl_skip_verify = true
|
||
|
|
bind_dn = "CORP\\%s"
|
||
|
|
search_filter = "(sAMAccountName=%s)"
|
||
|
|
search_base_dns = ["dc=corp,dc=local"]
|
||
|
|
|
||
|
|
[servers.attributes]
|
||
|
|
member_of = "memberOf"
|
||
|
|
email = "mail"
|
||
|
|
|
||
|
|
# [[servers.group_mappings]] omitted for clarity
|
||
|
|
```
|
||
|
|
|
||
|
|
#### Port requirements
|
||
|
|
|
||
|
|
In above example SSL is enabled and an encrypted port have been configured. If your Active Directory don't support SSL please change `enable_ssl = false` and `port = 389`.
|
||
|
4 years ago
|
Please inspect your Active Directory configuration and documentation to find the correct settings. For more information about Active Directory and port requirements see [link](<https://technet.microsoft.com/en-us/library/dd772723(v=ws.10)>).
|
||
|
7 years ago
|
|
||
|
|
## Troubleshooting
|
||
|
|
|
||
|
4 years ago
|
To troubleshoot and get more log info enable LDAP debug logging in the [main config file]({{< relref "../../configure-grafana/" >}}).
|
||
|
7 years ago
|
|
||
|
|
```bash
|
||
|
|
[log]
|
||
|
|
filters = ldap:debug
|
||
|
|
```
|