1
1
[[file-realm]]
2
2
=== File-based User Authentication
3
3
4
- You can manage and authenticate users with the built-in `file` internal realm.
5
- With the `file` realm users are defined in local files on each node in the cluster.
4
+ You can manage and authenticate users with the built-in `file` realm.
5
+ With the `file` realm, users are defined in local files on each node in the cluster.
6
6
7
7
IMPORTANT: As the administrator of the cluster, it is your responsibility to
8
8
ensure the same users are defined on every node in the cluster.
@@ -20,102 +20,7 @@ realms you specify are used for authentication. To use the
20
20
21
21
To define users, {security} provides the {ref}/users-command.html[users]
22
22
command-line tool. This tool enables you to add and remove users, assign user
23
- roles and manage user passwords.
23
+ roles, and manage user passwords.
24
24
25
- ==== Configuring a File Realm
26
-
27
- The `file` realm is added to the realm chain by default. You don't need to
28
- explicitly configure a `file` realm to manage users with the `users` tool.
29
-
30
- Like other realms, you can configure options for a `file` realm in the
31
- `xpack.security.authc.realms` namespace in `elasticsearch.yml`.
32
-
33
- To configure an `file` realm:
34
-
35
- . Add a realm configuration of type `file` to `elasticsearch.yml` under the
36
- `xpack.security.authc.realms` namespace. At a minimum, you must set the realm `type` to
37
- `file`. If you are configuring multiple realms, you should also explicitly set
38
- the `order` attribute. See <<file-realm-settings>> for all of the options you can set
39
- for a `file` realm.
40
- +
41
- For example, the following snippet shows a `file` realm configuration that sets
42
- the `order` to zero so the realm is checked first:
43
- +
44
- [source, yaml]
45
- ------------------------------------------------------------
46
- xpack:
47
- security:
48
- authc:
49
- realms:
50
- file1:
51
- type: file
52
- order: 0
53
- ------------------------------------------------------------
54
-
55
- . Restart Elasticsearch.
56
-
57
- [[file-realm-settings]]
58
- ===== File Realm Settings
59
-
60
- See {ref}/security-settings.html#ref-users-settings[File Realm Settings].
61
-
62
- ==== A Look Under the Hood
63
-
64
- All the data about the users for the `file` realm is stored in two files, `users`
65
- and `users_roles`. Both files are located in `CONFIG_DIR/x-pack/` and are read
66
- on startup.
67
-
68
- By default, {security} checks these files for changes every 5 seconds. You can
69
- change this default behavior by changing the `resource.reload.interval.high` setting in
70
- the `elasticsearch.yml` file (as this is a common setting in Elasticsearch,
71
- changing its value may effect other schedules in the system).
72
-
73
- [IMPORTANT]
74
- ==============================
75
- These files are managed locally by the node and are **not** managed
76
- globally by the cluster. This means that with a typical multi-node cluster,
77
- the exact same changes need to be applied on each and every node in the
78
- cluster.
79
-
80
- A safer approach would be to apply the change on one of the nodes and have the
81
- `users` and `users_roles` files distributed/copied to all other nodes in the
82
- cluster (either manually or using a configuration management system such as
83
- Puppet or Chef).
84
- ==============================
85
-
86
- While it is possible to modify these files directly using any standard text
87
- editor, we strongly recommend using the {ref}/users-command.html[`bin/elasticsearch-users`]
88
- command-line tool to apply the required changes.
89
-
90
- [float]
91
- [[users-file]]
92
- ===== The `users` File
93
- The `users` file stores all the users and their passwords. Each line in the
94
- `users` file represents a single user entry consisting of the username and
95
- **hashed** password.
96
-
97
- [source,bash]
98
- ----------------------------------------------------------------------
99
- rdeniro:$2a$10$BBJ/ILiyJ1eBTYoRKxkqbuDEdYECplvxnqQ47uiowE7yGqvCEgj9W
100
- alpacino:$2a$10$cNwHnElYiMYZ/T3K4PvzGeJ1KbpXZp2PfoQD.gfaVdImnHOwIuBKS
101
- jacknich:$2a$10$GYUNWyABV/Ols/.bcwxuBuuaQzV6WIauW6RdboojxcixBq3LtI3ni
102
- ----------------------------------------------------------------------
103
-
104
- NOTE: {security} uses `bcrypt` to hash the user passwords.
105
-
106
- [float]
107
- [[users_defining-roles]]
108
- ==== The `users_roles` File
109
-
110
- The `users_roles` file stores the roles associated with the users, as in the
111
- following example:
112
-
113
- [source,shell]
114
- --------------------------------------------------
115
- admin:rdeniro
116
- power_user:alpacino,jacknich
117
- user:jacknich
118
- --------------------------------------------------
119
-
120
- Each row maps a role to a comma-separated list of all the users that are
121
- associated with that role.
25
+ For more information, see
26
+ {ref}/configuring-file-realm.html[Configuring a file realm].
0 commit comments