configuring-active-directory-realm.asciidoc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. To integrate with Active Directory, you configure an `active_directory`
  2. realm and map Active Directory users and groups to roles in the role mapping file.
  3. . Add a realm configuration of type `active_directory` to `elasticsearch.yml`
  4. under the `xpack.security.authc.realms.active_directory` namespace.
  5. At a minimum, you must specify the Active Directory `domain_name` and `order`.
  6. +
  7. --
  8. See <<ref-ad-settings>> for all of the options you can set for an
  9. `active_directory` realm.
  10. NOTE: Binding to Active Directory fails if the domain name is not mapped in DNS.
  11. If DNS is not being provided by a Windows DNS server, add a mapping for
  12. the domain in the local `/etc/hosts` file.
  13. For example, the following realm configuration configures {es} to connect
  14. to `ldaps://example.com:636` to authenticate users through Active Directory:
  15. [source, yaml]
  16. ------------------------------------------------------------
  17. xpack:
  18. security:
  19. authc:
  20. realms:
  21. active_directory:
  22. my_ad:
  23. order: 0 <1>
  24. domain_name: ad.example.com
  25. url: ldaps://ad.example.com:636 <2>
  26. ------------------------------------------------------------
  27. <1> The realm order controls the order in which the configured realms are checked
  28. when authenticating a user.
  29. <2> If you don't specify the URL, it defaults to `ldap:<domain_name>:389`.
  30. IMPORTANT: When you configure realms in `elasticsearch.yml`, only the
  31. realms you specify are used for authentication. If you also want to use the
  32. `native` or `file` realms, you must include them in the realm chain.
  33. --
  34. . If you are authenticating users across multiple domains in a forest, extra
  35. steps are required. There are a few minor differences in the configuration and
  36. the way that users authenticate.
  37. +
  38. --
  39. Set the `domain_name` setting to the forest root domain name.
  40. You must also set the `url` setting, since you must authenticate against the
  41. Global Catalog, which uses a different port and might not be running on every
  42. Domain Controller.
  43. For example, the following realm configuration configures {es} to connect
  44. to specific Domain Controllers on the Global Catalog port with the domain name
  45. set to the forest root:
  46. [source, yaml]
  47. ------------------------------------------------------------
  48. xpack:
  49. security:
  50. authc:
  51. realms:
  52. active_directory:
  53. my_ad:
  54. order: 0
  55. domain_name: example.com <1>
  56. url: ldaps://dc1.ad.example.com:3269, ldaps://dc2.ad.example.com:3269 <2>
  57. load_balance:
  58. type: "round_robin" <3>
  59. ------------------------------------------------------------
  60. <1> The `domain_name` is set to the name of the root domain in the forest.
  61. <2> The `url` value used in this example has URLs for two different Domain Controllers,
  62. which are also Global Catalog servers. Port 3268 is the default port for unencrypted
  63. communication with the Global Catalog; port 3269 is the default port for SSL connections.
  64. The servers that are being connected to can be in any domain of the forest as long as
  65. they are also Global Catalog servers.
  66. <3> A load balancing setting is provided to indicate the desired behavior when choosing
  67. the server to connect to.
  68. In this configuration, users will need to use either their full User Principal
  69. Name (UPN) or their Down-Level Logon Name. A UPN is typically a concatenation of
  70. the username with `@<DOMAIN_NAME` such as `johndoe@ad.example.com`. The Down-Level
  71. Logon Name is the NetBIOS domain name, followed by a `\` and the username, such as
  72. `AD\johndoe`. Use of Down-Level Logon Name requires a connection to the regular LDAP
  73. ports (389 or 636) in order to query the configuration container to retrieve the
  74. domain name from the NetBIOS name.
  75. --
  76. . (Optional) Configure how {es} should interact with multiple Active
  77. Directory servers.
  78. +
  79. --
  80. The `load_balance.type` setting can be used at the realm level. Two modes of
  81. operation are supported: failover and load balancing. See <<ref-ad-settings>>.
  82. --
  83. . (Optional) To protect passwords,
  84. <<tls-active-directory,encrypt communications between {es} and the Active Directory server>>.
  85. . Restart {es}.
  86. . Configure a bind user.
  87. +
  88. --
  89. The Active Directory realm authenticates users using an LDAP bind request. By
  90. default, all of the LDAP operations are run by the user that {es} is
  91. authenticating. In some cases, regular users may not be able to access all of the
  92. necessary items within Active Directory and a _bind user_ is needed. A bind user
  93. can be configured and is used to perform all operations other than the LDAP bind
  94. request, which is required to authenticate the credentials provided by the user.
  95. The use of a bind user enables the
  96. <<run-as-privilege,run as feature>> to be used with the Active
  97. Directory realm and the ability to maintain a set of pooled connections to
  98. Active Directory. These pooled connection reduce the number of resources that
  99. must be created and destroyed with every user authentication.
  100. The following example shows the configuration of a bind user through the user of
  101. the `bind_dn` and `secure_bind_password` settings:
  102. [source, yaml]
  103. ------------------------------------------------------------
  104. xpack:
  105. security:
  106. authc:
  107. realms:
  108. active_directory:
  109. my_ad:
  110. order: 0
  111. domain_name: ad.example.com
  112. url: ldaps://ad.example.com:636
  113. bind_dn: es_svc_user@ad.example.com <1>
  114. ------------------------------------------------------------
  115. <1> This is the user that all Active Directory search requests are executed as.
  116. Without a bind user configured, all requests run as the user that is authenticating
  117. with {es}.
  118. The password for the `bind_dn` user should be configured by adding the
  119. appropriate `secure_bind_password` setting to the {es} keystore. For example,
  120. the following command adds the password for the example realm above:
  121. [source, shell]
  122. ------------------------------------------------------------
  123. bin/elasticsearch-keystore add \
  124. xpack.security.authc.realms.active_directory.my_ad.secure_bind_password
  125. ------------------------------------------------------------
  126. When a bind user is configured, connection pooling is enabled by default.
  127. Connection pooling can be disabled using the `user_search.pool.enabled` setting.
  128. --
  129. . Map Active Directory users and groups to roles.
  130. +
  131. --
  132. An integral part of a realm authentication process is to resolve the roles
  133. associated with the authenticated user. Roles define the privileges a user has
  134. in the cluster.
  135. Since with the `active_directory` realm the users are managed externally in the
  136. Active Directory server, the expectation is that their roles are managed there
  137. as well. In fact, Active Directory supports the notion of groups, which often
  138. represent user roles for different systems in the organization.
  139. The `active_directory` realm enables you to map Active Directory users to roles
  140. via their Active Directory groups or other metadata. This role mapping can be
  141. configured via the <<security-role-mapping-apis,role-mapping APIs>> or by using
  142. a file stored on each node. When a user authenticates against an Active
  143. Directory realm, the privileges for that user are the union of all privileges
  144. defined by the roles to which the user is mapped.
  145. Within a mapping definition, you specify groups using their distinguished
  146. names. For example, the following mapping configuration maps the Active
  147. Directory `admins` group to both the `monitoring` and `user` roles, maps the
  148. `users` group to the `user` role and maps the `John Doe` user to the `user`
  149. role.
  150. Configured via the role-mapping API:
  151. [source,console]
  152. --------------------------------------------------
  153. PUT /_security/role_mapping/admins
  154. {
  155. "roles" : [ "monitoring" , "user" ],
  156. "rules" : { "field" : {
  157. "groups" : "cn=admins,dc=example,dc=com" <1>
  158. } },
  159. "enabled": true
  160. }
  161. --------------------------------------------------
  162. <1> The Active Directory distinguished name (DN) of the `admins` group.
  163. [source,console]
  164. --------------------------------------------------
  165. PUT /_security/role_mapping/basic_users
  166. {
  167. "roles" : [ "user" ],
  168. "rules" : { "any": [
  169. { "field" : {
  170. "groups" : "cn=users,dc=example,dc=com" <1>
  171. } },
  172. { "field" : {
  173. "dn" : "cn=John Doe,cn=contractors,dc=example,dc=com" <2>
  174. } }
  175. ] },
  176. "enabled": true
  177. }
  178. --------------------------------------------------
  179. <1> The Active Directory distinguished name (DN) of the `users` group.
  180. <2> The Active Directory distinguished name (DN) of the user `John Doe`.
  181. Or, alternatively, configured via the role-mapping file:
  182. [source, yaml]
  183. ------------------------------------------------------------
  184. monitoring: <1>
  185. - "cn=admins,dc=example,dc=com" <2>
  186. user:
  187. - "cn=users,dc=example,dc=com" <3>
  188. - "cn=admins,dc=example,dc=com"
  189. - "cn=John Doe,cn=contractors,dc=example,dc=com" <4>
  190. ------------------------------------------------------------
  191. <1> The name of the role.
  192. <2> The Active Directory distinguished name (DN) of the `admins` group.
  193. <3> The Active Directory distinguished name (DN) of the `users` group.
  194. <4> The Active Directory distinguished name (DN) of the user `John Doe`.
  195. For more information, see
  196. <<mapping-roles>>.
  197. --
  198. . (Optional) Configure the `metadata` setting in the Active Directory realm to
  199. include extra properties in the user's metadata.
  200. +
  201. --
  202. By default, `ldap_dn` and `ldap_groups` are populated in the user's metadata.
  203. For more information, see
  204. <<ad-user-metadata>>.
  205. --