configuring-kerberos-realm.asciidoc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. [role="xpack"]
  2. [[configuring-kerberos-realm]]
  3. === Configuring a Kerberos realm
  4. Kerberos is used to protect services and uses a ticket-based authentication
  5. protocol to authenticate users.
  6. You can configure {es} to use the Kerberos V5 authentication protocol, which is
  7. an industry standard protocol, to authenticate users.
  8. In this scenario, clients must present Kerberos tickets for authentication.
  9. In Kerberos, users authenticate with an authentication service and later
  10. with a ticket granting service to generate a TGT (ticket-granting ticket).
  11. This ticket is then presented to the service for authentication.
  12. Refer to your Kerberos installation documentation for more information about
  13. obtaining TGT. {es} clients must first obtain a TGT then initiate the process of
  14. authenticating with {es}.
  15. For a summary of Kerberos terminology, see {stack-ov}/kerberos-realm.html[Kerberos authentication].
  16. ==== Before you begin
  17. . Deploy Kerberos.
  18. +
  19. --
  20. You must have the Kerberos infrastructure set up in your environment.
  21. NOTE: Kerberos requires a lot of external services to function properly, such as
  22. time synchronization between all machines and working forward and reverse DNS
  23. mappings in your domain. Refer to your Kerberos documentation for more details.
  24. These instructions do not cover setting up and configuring your Kerberos
  25. deployment. Where examples are provided, they pertain to an MIT Kerberos V5
  26. deployment. For more information, see
  27. http://web.mit.edu/kerberos/www/index.html[MIT Kerberos documentation]
  28. --
  29. . Configure Java GSS.
  30. +
  31. --
  32. {es} uses Java GSS framework support for Kerberos authentication.
  33. To support Kerberos authentication, {es} needs the following files:
  34. * `krb5.conf`, a Kerberos configuration file
  35. * A `keytab` file that contains credentials for the {es} service principal
  36. The configuration requirements depend on your Kerberos setup. Refer to your
  37. Kerberos documentation to configure the `krb5.conf` file.
  38. For more information on Java GSS, see
  39. https://docs.oracle.com/javase/10/security/kerberos-requirements1.htm[Java GSS Kerberos requirements]
  40. --
  41. ==== Create a Kerberos realm
  42. To configure a Kerberos realm in {es}:
  43. . Configure the JVM to find the Kerberos configuration file.
  44. +
  45. --
  46. {es} uses Java GSS and JAAS Krb5LoginModule to support Kerberos authentication
  47. using a Simple and Protected GSSAPI Negotiation Mechanism (SPNEGO) mechanism.
  48. The Kerberos configuration file (`krb5.conf`) provides information such as the
  49. default realm, the Key Distribution Center (KDC), and other configuration details
  50. required for Kerberos authentication. When the JVM needs some configuration
  51. properties, it tries to find those values by locating and loading this file. The
  52. JVM system property to configure the file path is `java.security.krb5.conf`. To
  53. configure JVM system properties see {ref}/jvm-options.html[configuring jvm options].
  54. If this system property is not specified, Java tries to locate the file based on
  55. the conventions.
  56. TIP: It is recommended that this system property be configured for {es}.
  57. The method for setting this property depends on your Kerberos infrastructure.
  58. Refer to your Kerberos documentation for more details.
  59. For more information, see http://web.mit.edu/kerberos/krb5-latest/doc/admin/conf_files/krb5_conf.html[krb5.conf]
  60. --
  61. . Create a keytab for the {es} node.
  62. +
  63. --
  64. A keytab is a file that stores pairs of principals and encryption keys. {es}
  65. uses the keys from the keytab to decrypt the tickets presented by the user. You
  66. must create a keytab for {es} by using the tools provided by your Kerberos
  67. implementation. For example, some tools that create keytabs are `ktpass.exe` on
  68. Windows and `kadmin` for MIT Kerberos.
  69. --
  70. . Put the keytab file in the {es} configuration directory.
  71. +
  72. --
  73. Make sure that this keytab file has read permissions. This file contains
  74. credentials, therefore you must take appropriate measures to protect it.
  75. IMPORTANT: {es} uses Kerberos on the HTTP network layer, therefore there must be
  76. a keytab file for the HTTP service principal on every {es} node. The service
  77. principal name must have the format `HTTP/es.domain.local@ES.DOMAIN.LOCAL`.
  78. The keytab files are unique for each node since they include the hostname.
  79. An {es} node can act as any principal a client requests as long as that
  80. principal and its credentials are found in the configured keytab.
  81. --
  82. . Create a Kerberos realm.
  83. +
  84. --
  85. To enable Kerberos authentication in {es}, you must add a Kerberos realm in the
  86. realm chain.
  87. NOTE: You can configure only one Kerberos realm on {es} nodes.
  88. To configure a Kerberos realm, there are a few mandatory realm settings and
  89. other optional settings that you need to configure in the `elasticsearch.yml`
  90. configuration file. Add a realm configuration under the
  91. `xpack.security.authc.realms.kerberos` namespace.
  92. The most common configuration for a Kerberos realm is as follows:
  93. [source, yaml]
  94. ------------------------------------------------------------
  95. xpack.security.authc.realms.kerberos.kerb1:
  96. order: 3
  97. keytab.path: es.keytab
  98. remove_realm_name: false
  99. ------------------------------------------------------------
  100. The `username` is extracted from the ticket presented by user and usually has
  101. the format `username@REALM`. This `username` is used for mapping
  102. roles to the user. If realm setting `remove_realm_name` is
  103. set to `true`, the realm part (`@REALM`) is removed. The resulting `username`
  104. is used for role mapping.
  105. For detailed information of available realm settings,
  106. see {ref}/security-settings.html#ref-kerberos-settings[Kerberos realm settings].
  107. --
  108. . Restart {es}
  109. . Map Kerberos users to roles.
  110. +
  111. --
  112. The `kerberos` realm enables you to map Kerberos users to roles. You can
  113. configure these role mappings by using the
  114. {ref}/security-api-role-mapping.html[role-mapping API]. You identify
  115. users by their `username` field.
  116. The following example uses the role mapping API to map `user@REALM` to the roles
  117. `monitoring` and `user`:
  118. [source,js]
  119. --------------------------------------------------
  120. POST /_security/role_mapping/kerbrolemapping
  121. {
  122. "roles" : [ "monitoring_user" ],
  123. "enabled": true,
  124. "rules" : {
  125. "field" : { "username" : "user@REALM" }
  126. }
  127. }
  128. --------------------------------------------------
  129. // CONSOLE
  130. In case you want to support Kerberos cross realm authentication you may
  131. need to map roles based on the Kerberos realm name. For such scenarios
  132. following are the additional user metadata available for role mapping:
  133. - `kerberos_realm` will be set to Kerberos realm name.
  134. - `kerberos_user_principal_name` will be set to user principal name from the Kerberos ticket.
  135. For more information, see {stack-ov}/mapping-roles.html[Mapping users and groups to roles].
  136. NOTE: The Kerberos realm supports
  137. {stack-ov}/realm-chains.html#authorization_realms[authorization realms] as an
  138. alternative to role mapping.
  139. --