configuring-file-realm.asciidoc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. [role="xpack"]
  2. [[configuring-file-realm]]
  3. === Configuring a file realm
  4. You can manage and authenticate users with the built-in `file` internal realm.
  5. All the data about the users for the `file` realm is stored in two files on each
  6. node in the cluster: `users` and `users_roles`. Both files are located in
  7. `ES_PATH_CONF` and are read on startup.
  8. [IMPORTANT]
  9. ==============================
  10. The `users` and `users_roles` files are managed locally by the node and are
  11. **not** managed globally by the cluster. This means that with a typical
  12. multi-node cluster, the exact same changes need to be applied on each and every
  13. node in the cluster.
  14. A safer approach would be to apply the change on one of the nodes and have the
  15. files distributed or copied to all other nodes in the cluster (either manually
  16. or using a configuration management system such as Puppet or Chef).
  17. ==============================
  18. The `file` realm is added to the realm chain by default. You don't need to
  19. explicitly configure a `file` realm.
  20. For more information about file realms, see
  21. {xpack-ref}/file-realm.html[File-based user authentication].
  22. . (Optional) Add a realm configuration of type `file` to `elasticsearch.yml`
  23. under the `xpack.security.authc.realms` namespace. At a minimum, you must set
  24. the realm `type` to `file`. If you are configuring multiple realms, you should
  25. also explicitly set the `order` attribute.
  26. +
  27. --
  28. //See <<ref-users-settings>> for all of the options you can set for a `file` realm.
  29. For example, the following snippet shows a `file` realm configuration that sets
  30. the `order` to zero so the realm is checked first:
  31. [source, yaml]
  32. ------------------------------------------------------------
  33. xpack:
  34. security:
  35. authc:
  36. realms:
  37. file1:
  38. type: file
  39. order: 0
  40. ------------------------------------------------------------
  41. --
  42. . Restart {es}.
  43. . Add user information to the `ES_PATH_CONF/users` file on each node in the
  44. cluster.
  45. +
  46. --
  47. The `users` file stores all the users and their passwords. Each line in the file
  48. represents a single user entry consisting of the username and **hashed** and **salted** password.
  49. [source,bash]
  50. ----------------------------------------------------------------------
  51. rdeniro:$2a$10$BBJ/ILiyJ1eBTYoRKxkqbuDEdYECplvxnqQ47uiowE7yGqvCEgj9W
  52. alpacino:$2a$10$cNwHnElYiMYZ/T3K4PvzGeJ1KbpXZp2PfoQD.gfaVdImnHOwIuBKS
  53. jacknich:{PBKDF2}50000$z1CLJt0MEFjkIK5iEfgvfnA6xq7lF25uasspsTKSo5Q=$XxCVLbaKDimOdyWgLCLJiyoiWpA/XDMe/xtVgn1r5Sg=
  54. ----------------------------------------------------------------------
  55. NOTE: To limit exposure to credential theft and mitigate credential compromise,
  56. the file realm stores passwords and caches user credentials according to
  57. security best practices. By default, a hashed version of user credentials
  58. is stored in memory, using a salted `sha-256` hash algorithm and a hashed
  59. version of passwords is stored on disk salted and hashed with the `bcrypt`
  60. hash algorithm. To use different hash algorithms, see <<hashing-settings>>.
  61. While it is possible to modify the `users` files directly using any standard text
  62. editor, we strongly recommend using the <<users-command>> tool to apply the
  63. required changes.
  64. IMPORTANT: As the administrator of the cluster, it is your responsibility to
  65. ensure the same users are defined on every node in the cluster.
  66. {security} does not deliver any mechanism to guarantee this.
  67. --
  68. . Add role information to the `ES_PATH_CONF/users_roles` file on each node
  69. in the cluster.
  70. +
  71. --
  72. The `users_roles` file stores the roles associated with the users. For example:
  73. [source,shell]
  74. --------------------------------------------------
  75. admin:rdeniro
  76. power_user:alpacino,jacknich
  77. user:jacknich
  78. --------------------------------------------------
  79. Each row maps a role to a comma-separated list of all the users that are
  80. associated with that role.
  81. You can use the <<users-command>> tool to update this file. You must ensure that
  82. the same changes are made on every node in the cluster.
  83. --
  84. . (Optional) Change how often the `users` and `users_roles` files are checked.
  85. +
  86. --
  87. By default, {security} checks these files for changes every 5 seconds. You can
  88. change this default behavior by changing the `resource.reload.interval.high`
  89. setting in the `elasticsearch.yml` file (as this is a common setting in {es},
  90. changing its value may effect other schedules in the system).
  91. --