grafana/docs/sources/installation/ldap.md
Torkel Ödegaard 96008c9738 Squashed commit of the following:
commit 4113ed00782590187d19dd2f8cbae683f164142c
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Fri Oct 21 10:47:35 2016 +0200

    docs(): minor fix for docs index page

commit 45478d120571519462fac905aadeab5954696690
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Thu Oct 20 14:28:21 2016 +0200

    updated

commit c9c1c1d5a462f85e8001a45218f24102583d7aee
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Thu Oct 20 14:27:34 2016 +0200

    docs(): updated image refs

commit 5fa0f27963968d77bbbbb7edd973847ea72135e3
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Wed Oct 19 14:33:04 2016 +0200

    docs is almost done

commit 6b988c90cb08563e2c27212338c2947e69f6fcc3
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Tue Oct 18 20:45:28 2016 +0200

    almost done

commit 17757c21ed813892ddb1f289f2e52613caf7bcef
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Tue Oct 18 16:45:48 2016 +0200

    making progress on docs

commit f06c815991dd81b8893912a6da04a17b80b63fda
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Tue Oct 18 14:30:55 2016 +0200

    progress on new docs

commit 5197237426252623de2d8b9cc22ddbbdbb240763
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Tue Oct 18 13:25:26 2016 +0200

    making progress

commit 33e2b6b617f16f65878141cf11e54b2817a2ea96
Merge: de385e5 ecb4a99
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Tue Oct 18 12:17:58 2016 +0200

    Merge branch 'new-docs' of github.com:grafana/grafana into new-docs

commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Tue Oct 18 10:39:59 2016 +0200

    keep urls for now

commit de385e56d86b071cf2150ccf9f1aa06ec5187277
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Mon Oct 17 17:56:18 2016 +0200

    more progress

commit 8469ebc239ab2316cbbc01862e5026737f272f00
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Mon Oct 17 17:08:06 2016 +0200

    progress on new docs

commit e755f656b12534cfcb23bad11f1fa696e43f7428
Merge: 4644a35 35cce3b
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Mon Oct 17 12:21:27 2016 +0200

    Merge branch 'new-docs' of github.com:grafana/grafana into new-docs

commit 4644a35102555204787e91041b50dcbfe0f7a213
Merge: 25c4bef 977cdd5
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Mon Oct 17 12:21:11 2016 +0200

    Merge branch 'master' of github.com:grafana/grafana into new-docs

commit 35cce3bef802fac020a53693b02c112a91a096fc
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Mon Oct 17 09:31:17 2016 +0200

    progress on #6170

commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6
Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
Date:   Sun Oct 16 15:05:30 2016 +0200

    fix for osx

commit 6c6b52f975630be87da23dd51beafaecb820cec2
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Sun Oct 16 12:56:39 2016 +0200

    progress on new docs

commit 6a09633981ab26191d5542dbe3a788846ac6b73d
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Sat Oct 15 11:39:49 2016 +0200

    progress on new docs

commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Mon Oct 10 09:25:12 2016 +0200

    making progress on new docs site

commit 50392ce98edfa201977716e92e4a86f9d48ae386
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Sun Oct 9 20:02:28 2016 +0200

    feat(new docs): progress on new docs site

commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Fri Oct 7 07:52:11 2016 +0200

    new docs site experiment

commit 704adc98664665b3624087ab38ce29fc9da005f1
Author: Torkel Ödegaard <torkel@grafana.org>
Date:   Sat Oct 1 20:46:53 2016 +0200

    new docs poc
2016-10-21 11:01:34 +02:00

5.0 KiB

+++ title = "LDAP Authentication" description = "Grafana LDAP Authentication Guide " keywords = ["grafana", "configuration", "documentation", "ldap"] type = "docs" [menu.docs] name = "LDAP Authentication" identifier = "ldap" parent = "admin" weight = 2 +++

LDAP Authentication

Grafana (2.1 and newer) ships with a strong LDAP integration feature. The LDAP integration in Grafana allows your Grafana users to login with their LDAP credentials. You can also specify mappings between LDAP group memberships and Grafana Organization user roles.

Configuration

You turn on LDAP in the [main config file]({{< relref "configuration.md#auth-ldap" >}}) as well as specify the path to the LDAP specific configuration file (default: /etc/grafana/ldap.toml).

Example config

# Set to true to log user information returned from LDAP
verbose_logging = false

[[servers]]
# Ldap server host (specify multiple hosts space separated)
host = "127.0.0.1"
# Default port is 389 or 636 if use_ssl = true
port = 389
# Set to true if ldap server supports TLS
use_ssl = false
# Set to true if connect ldap server with STARTTLS pattern (create connection in insecure, then upgrade to secure connection with TLS)
start_tls = false
# set to true if you want to skip ssl cert validation
ssl_skip_verify = false
# set to the path to your root CA certificate or leave unset to use system defaults
# root_ca_cert = /path/to/certificate.crt

# Search user bind dn
bind_dn = "cn=admin,dc=grafana,dc=org"
# Search user bind password
bind_password = 'grafana'

# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
search_filter = "(cn=%s)"

# An array of base dns to search through
search_base_dns = ["dc=grafana,dc=org"]

# In POSIX LDAP schemas, without memberOf attribute a secondary query must be made for groups.
# This is done by enabling group_search_filter below. You must also set member_of= "cn"
# in [servers.attributes] below.

## 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"]

# Specify names of the ldap attributes your ldap uses
[servers.attributes]
name = "givenName"
surname = "sn"
username = "cn"
member_of = "memberOf"
email =  "email"

# Map ldap groups to grafana org roles
[[servers.group_mappings]]
group_dn = "cn=admins,dc=grafana,dc=org"
org_role = "Admin"
# The Grafana organization database id, optional, if left out the default org (id 1) will be used
# org_id = 1

[[servers.group_mappings]]
group_dn = "cn=users,dc=grafana,dc=org"
org_role = "Editor"

[[servers.group_mappings]]
# If you want to match all (or no ldap groups) then you can use wildcard
group_dn = "*"
org_role = "Viewer"

Bind & Bind Password

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. When the user DN is found a second bind is performed with the user provided username & password (in the normal Grafana login form).

bind_dn = "cn=admin,dc=grafana,dc=org"
bind_password = "grafana"

Single Bind Example

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. This allows you to not specify a bind_password in the configuration file.

bind_dn = "cn=%s,o=users,dc=grafana,dc=org"

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. 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).

POSIX schema (no memberOf attribute)

If your ldap server does not support the memberOf attribute add these options:

## 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"]

Also change set member_of = "cn" in the [servers.attributes] section.

LDAP to Grafana Org Role Sync

Mappings

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 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.

Priority

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 config will be used.