3
3
4
4
To use PKI in {es}, you configure a PKI realm, enable client authentication on
5
5
the desired network layers (transport or http), and map the Distinguished Names
6
- (DNs) from the Subject field in the user certificates to roles. You create the mappings in a role mapping file or use the role mappings API.
6
+ (DNs) from the Subject field in the user certificates to roles. You create the
7
+ mappings in a role mapping file or use the role mappings API.
7
8
8
- If you want the same users to also be authenticated using certificates when they connect to {kib}, you must configure the {es} PKI realm to
9
- <<pki-realm-for-proxied-clients,allow delegation>> and to
10
- {kibana-ref}/kibana-authentication.html#pki-authentication[enable PKI authentication in {kib}].
11
-
12
- You can also use a combination of PKI and username/password authentication. For
9
+ TIP: You can use a combination of PKI and username/password authentication. For
13
10
example, you can enable SSL/TLS on the transport layer and define a PKI realm to
14
11
require transport clients to authenticate with X.509 certificates, while still
15
- authenticating HTTP traffic using username and password credentials. You can
16
- also set `xpack.security.transport.ssl.client_authentication` to `optional` to
17
- allow clients without certificates to authenticate with other credentials.
18
-
19
- IMPORTANT: You must enable SSL/TLS with client authentication to use PKI when
20
- clients connect directly to {es}.
12
+ authenticating HTTP traffic using username and password credentials.
21
13
22
14
. Add a realm configuration for a `pki` realm to `elasticsearch.yml` under the
23
- `xpack.security.authc.realms.pki` namespace.
24
- You must explicitly set the `order` attribute. See <<ref-pki-settings>> for all
25
- of the options you can set for a `pki` realm.
15
+ `xpack.security.authc.realms.pki` namespace. You must explicitly set the `order`
16
+ attribute. See <<ref-pki-settings>> for all of the options you can set for a
17
+ `pki` realm.
26
18
+
27
19
--
28
20
For example, the following snippet shows the most basic `pki` realm configuration:
@@ -41,15 +33,21 @@ xpack:
41
33
With this configuration, any certificate trusted by the {es} SSL/TLS layer is
42
34
accepted for authentication. The username is the common name (CN) extracted
43
35
from the DN in the Subject field of the end-entity certificate. This
44
- configuration does not permit PKI authentication to {kib}.
36
+ configuration is not sufficient to permit PKI authentication to {kib};
37
+ additional steps are required.
45
38
46
39
IMPORTANT: When you configure realms in `elasticsearch.yml`, only the
47
40
realms you specify are used for authentication. If you also want to use the
48
41
`native` or `file` realms, you must include them in the realm chain.
49
42
50
- If you want to use something other than the CN of the Subject DN as the
51
- username, you can specify a regex to extract the desired username. The regex is
52
- applied on the Subject DN. For example, the regex in the following
43
+ --
44
+
45
+ . Optional: If you want to use something other than the CN of the Subject DN as
46
+ the username, you can specify a regex to extract the desired username. The regex
47
+ is applied on the Subject DN.
48
+ +
49
+ --
50
+ For example, the regex in the following
53
51
configuration extracts the email address from the Subject DN:
54
52
55
53
[source, yaml]
@@ -69,6 +67,10 @@ client's certificate, then the realm does not authenticate the certificate.
69
67
70
68
--
71
69
70
+ . Optional: If you want the same users to also be authenticated using
71
+ certificates when they connect to {kib}, you must configure the {es} PKI realm
72
+ to allow delegation. See <<pki-realm-for-proxied-clients>>.
73
+
72
74
. Restart {es} because realm configuration is not reloaded automatically. If
73
75
you're following through with the next steps, you might wish to hold the
74
76
restart for last.
@@ -78,6 +80,11 @@ restart for last.
78
80
. Enable client authentication on the desired network layers (transport or http).
79
81
+
80
82
--
83
+ IMPORTANT: To use PKI when clients connect directly to {es}, you must enable
84
+ SSL/TLS with client authentication. That is to say, you must set `xpack.security.transport.ssl.client_authentication` and
85
+ `xpack.security.http.ssl.client_authentication` to `optional` or `required`. If
86
+ the setting value is `optional`, clients without certificates can authenticate
87
+ with other credentials.
81
88
82
89
When clients connect directly to {es} and are not proxy-authenticated, the PKI
83
90
realm relies on the TLS settings of the node's network interface. The realm can
@@ -93,22 +100,22 @@ In particular this means:
93
100
`client_authentication` to `optional` or `required`.
94
101
* The interface must _trust_ the certificate that is presented by the client
95
102
by configuring either the `truststore` or `certificate_authorities` paths,
96
- or by setting `verification_mode` to `none`. See
97
- <<ssl-tls-settings,`ssl.verification_mode`>> for an explanation of this
98
- setting.
103
+ or by setting `verification_mode` to `none`.
99
104
* The _protocols_ supported by the interface must be compatible with those
100
105
used by the client.
106
+
107
+ For an explanation of these settings, see <<ssl-tls-settings>>.
101
108
102
109
The relevant network interface (transport or http) must be configured to trust
103
- any certificate that is to be used within the PKI realm. However, it is possible to
104
- configure the PKI realm to trust only a _subset_ of the certificates accepted
110
+ any certificate that is to be used within the PKI realm. However, it is possible
111
+ to configure the PKI realm to trust only a _subset_ of the certificates accepted
105
112
by the network interface. This is useful when the SSL/TLS layer trusts clients
106
113
with certificates that are signed by a different CA than the one that signs your
107
114
users' certificates.
108
115
109
116
To configure the PKI realm with its own truststore, specify the
110
117
`truststore.path` option. The path must be located within the Elasticsearch
111
- configuration directory (ES_PATH_CONF). For example:
118
+ configuration directory (` ES_PATH_CONF` ). For example:
112
119
113
120
[source, yaml]
114
121
------------------------------------------------------------
@@ -134,25 +141,23 @@ xpack.security.authc.realms.pki.pki1.truststore.secure_password
134
141
------------------------------------------------------------
135
142
136
143
The `certificate_authorities` option can be used as an alternative to the
137
- `truststore.path` setting, when the certificate files are PEM formatted
138
- . The setting accepts a list. The two options are exclusive, they cannot be both used
144
+ `truststore.path` setting, when the certificate files are PEM formatted. The
145
+ setting accepts a list. The two options are exclusive, they cannot be both used
139
146
simultaneously.
140
147
--
141
148
142
149
. Map roles for PKI users.
143
150
+
144
151
--
145
- You map roles for PKI users through the <<security-role-mapping-apis,role
146
- mapping APIs>> or by using a file stored on each node. Both configuration
147
- options are merged together. When a user authenticates against a PKI realm, the
148
- privileges for that user are the union of all privileges defined by the roles
149
- to which the user is mapped.
152
+ You map roles for PKI users through the
153
+ <<security-role- mapping-apis,role mapping APIs>> or by using a file stored on
154
+ each node. Both configuration options are merged together. When a user
155
+ authenticates against a PKI realm, the privileges for that user are the union of
156
+ all privileges defined by the roles to which the user is mapped.
150
157
151
158
You identify a user by the distinguished name in their certificate.
152
159
For example, the following mapping configuration maps `John Doe` to the
153
- `user` role:
154
-
155
- Using the role-mapping API:
160
+ `user` role using the role mapping API:
156
161
157
162
[source,console]
158
163
--------------------------------------------------
@@ -168,10 +173,7 @@ PUT /_security/role_mapping/users
168
173
169
174
<1> The distinguished name (DN) of a PKI user.
170
175
171
- Or, alternatively, configured inside a role-mapping file. The file's path
172
- defaults to `ES_PATH_CONF/role_mapping.yml`. You can specify a different path (which must be within
173
- ES_PATH_CONF) by using the `files.role_mapping` realm setting (e.g.
174
- `xpack.security.authc.realms.pki.pki1.files.role_mapping`):
176
+ Alternatively, use a role-mapping file. For example:
175
177
176
178
[source, yaml]
177
179
------------------------------------------------------------
@@ -181,9 +183,14 @@ user: <1>
181
183
<1> The name of a role.
182
184
<2> The distinguished name (DN) of a PKI user.
183
185
186
+ The file's path defaults to `ES_PATH_CONF/role_mapping.yml`. You can specify a
187
+ different path (which must be within `ES_PATH_CONF`) by using the
188
+ `files.role_mapping` realm setting (e.g.
189
+ `xpack.security.authc.realms.pki.pki1.files.role_mapping`).
190
+
184
191
The distinguished name for a PKI user follows X.500 naming conventions which
185
192
place the most specific fields (like `cn` or `uid`) at the beginning of the
186
- name, and the most general fields (like `o` or `dc`) at the end of the name.
193
+ name and the most general fields (like `o` or `dc`) at the end of the name.
187
194
Some tools, such as _openssl_, may print out the subject name in a different
188
195
format.
189
196
@@ -205,47 +212,60 @@ alternative to role mapping.
205
212
206
213
By default, the PKI realm relies on the node's network interface to perform the
207
214
SSL/TLS handshake and extract the client certificate. This behaviour requires
208
- that that clients connect directly to {es} so that their SSL connection is
209
- terminated by the {es} node. If SSL/TLS authenticatication is to be performed
210
- by {kib}, the PKI realm must be configured to permit delegation.
215
+ that clients connect directly to {es} so that their SSL connection is terminated
216
+ by the {es} node. If SSL/TLS authentication is to be performed by {kib}, the
217
+ PKI realm must be configured to permit delegation.
211
218
212
219
Specifically, when clients presenting X.509 certificates connect to {kib},
213
220
{kib} performs the SSL/TLS authentication. {kib} then forwards the client's
214
- certificate chain, by calling an {es} API, to have them further validated by
221
+ certificate chain ( by calling an {es} API) to have them further validated by
215
222
the PKI realms that have been configured for delegation.
216
223
217
224
To permit authentication delegation for a specific {es} PKI realm, start by
218
225
configuring the realm for the usual case, as detailed in the
219
- <<pki-realm-for-direct-clients>>
220
- section. Note that you must explicitly configure a `truststore` (or,
221
- equivalently `certificate_authorities`) even though it is the same trust
222
- configuration that you have configured on the network layer. Afterwards,
223
- simply toggle the `delegation.enabled` realm setting to `true`. This realm is
224
- now allowed to validate delegated PKI authentication (after restarting {es}).
226
+ <<pki-realm-for-direct-clients>> section. In this scenario, when you enable TLS,
227
+ it is mandatory that you <<tls-http,encrypt HTTP client communications>>.
225
228
226
- NOTE: PKI authentication delegation requires that the
227
- `xpack.security.authc.token.enabled` setting be `true` and that SSL/TLS be
228
- configured (without SSL/TLS client authentication).
229
+ You must also explicitly configure a `truststore` (or, equivalently
230
+ `certificate_authorities`) even though it is the same trust configuration that
231
+ you have configured on the network layer. The
232
+ `xpack.security.authc.token.enabled` and `delegation.enabled` settings must also
233
+ be `true`. For example:
234
+
235
+ [source, yaml]
236
+ ------------------------------------------------------------
237
+ xpack:
238
+ security:
239
+ authc:
240
+ token.enabled: true
241
+ realms:
242
+ pki:
243
+ pki1:
244
+ order: 1
245
+ delegation.enabled: true
246
+ truststore:
247
+ path: "pki1_truststore.jks"
248
+ ------------------------------------------------------------
229
249
230
- NOTE: {kib} also needs to be
231
- {kibana-ref}/kibana-authentication.html#pki-authentication[configured to allow
232
- PKI certificate authentication].
250
+ After you restart {es}, this realm can validate delegated PKI authentication.
251
+ You must then
252
+ {kibana-ref}/kibana-authentication.html#pki-authentication[configure {kib} to allow PKI certificate authentication].
233
253
234
254
A PKI realm with `delegation.enabled` still works unchanged for clients
235
- connecting directly to {es}. Directly authenticated users, and users that are PKI
255
+ connecting directly to {es}. Directly authenticated users and users that are PKI
236
256
authenticated by delegation to {kib} both follow the same
237
257
<<mapping-roles,role mapping rules>> or
238
258
<<authorization_realms,authorization realms configurations>>.
239
259
240
- However, if you use the <<security-role-mapping-apis,role mapping APIs>>,
241
- you can distinguish between users that are authenticated by delegation and
242
- users that are authenticated directly. The former have the
243
- extra fields `pki_delegated_by_user` and `pki_delegated_by_realm` in the user's
244
- metadata. In the common setup, where authentication is delegated to {kib}, the
245
- values of these fields are `kibana` and `reserved`, respectively. For example,
246
- the following role mapping rule will assign the `role_for_pki1_direct` role to
247
- all users that have been authenticated directly by the `pki1` realm, by
248
- connecting to {es} instead of going through {kib}:
260
+ If you use the <<security-role-mapping-apis,role mapping APIs>>, however, you
261
+ can distinguish between users that are authenticated by delegation and users
262
+ that are authenticated directly. The former have the extra fields
263
+ `pki_delegated_by_user` and `pki_delegated_by_realm` in the user's metadata. In
264
+ the common setup, where authentication is delegated to {kib}, the values of
265
+ these fields are `kibana` and `reserved`, respectively. For example, the
266
+ following role mapping rule assigns the `role_for_pki1_direct` role to all users
267
+ that have been authenticated directly by the `pki1` realm, by connecting to {es}
268
+ instead of going through {kib}:
249
269
250
270
[source,console]
251
271
--------------------------------------------------
@@ -268,5 +288,5 @@ PUT /_security/role_mapping/direct_pki_only
268
288
}
269
289
--------------------------------------------------
270
290
271
- <1> only when this metadata field is set (it is *not* `null`) the user has been
272
- authenticated in the delegation scenario.
291
+ <1> If this metadata field is set (that is to say, it is *not* `null`), the user
292
+ has been authenticated in the delegation scenario.
0 commit comments