configuring-file-realm.asciidoc 4.2 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 to `elasticsearch.yml` under the
  23. `xpack.security.authc.realms.file` namespace. At a minimum, you must set
  24. the realm's `order` attribute.
  25. +
  26. --
  27. //See <<ref-users-settings>> for all of the options you can set for a `file` realm.
  28. For example, the following snippet shows a `file` realm configuration that sets
  29. the `order` to zero so the realm is checked first:
  30. [source, yaml]
  31. ------------------------------------------------------------
  32. xpack:
  33. security:
  34. authc:
  35. realms:
  36. file:
  37. file1:
  38. order: 0
  39. ------------------------------------------------------------
  40. --
  41. . Restart {es}.
  42. . Add user information to the `ES_PATH_CONF/users` file on each node in the
  43. cluster.
  44. +
  45. --
  46. The `users` file stores all the users and their passwords. Each line in the file
  47. represents a single user entry consisting of the username and **hashed** and **salted** password.
  48. [source,bash]
  49. ----------------------------------------------------------------------
  50. rdeniro:$2a$10$BBJ/ILiyJ1eBTYoRKxkqbuDEdYECplvxnqQ47uiowE7yGqvCEgj9W
  51. alpacino:$2a$10$cNwHnElYiMYZ/T3K4PvzGeJ1KbpXZp2PfoQD.gfaVdImnHOwIuBKS
  52. jacknich:{PBKDF2}50000$z1CLJt0MEFjkIK5iEfgvfnA6xq7lF25uasspsTKSo5Q=$XxCVLbaKDimOdyWgLCLJiyoiWpA/XDMe/xtVgn1r5Sg=
  53. ----------------------------------------------------------------------
  54. NOTE: To limit exposure to credential theft and mitigate credential compromise,
  55. the file realm stores passwords and caches user credentials according to
  56. security best practices. By default, a hashed version of user credentials
  57. is stored in memory, using a salted `sha-256` hash algorithm and a hashed
  58. version of passwords is stored on disk salted and hashed with the `bcrypt`
  59. hash algorithm. To use different hash algorithms, see <<hashing-settings>>.
  60. While it is possible to modify the `users` files directly using any standard text
  61. editor, we strongly recommend using the <<users-command>> tool to apply the
  62. required changes.
  63. IMPORTANT: As the administrator of the cluster, it is your responsibility to
  64. ensure the same users are defined on every node in the cluster.
  65. The {es} {security-features} do not deliver any mechanisms to
  66. 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, {es} 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. --