Skip to content

Commit 859c644

Browse files
committed
[DOCS] Adds PKI delegation.enabled example (#53030)
1 parent 302980e commit 859c644

File tree

2 files changed

+89
-72
lines changed

2 files changed

+89
-72
lines changed

x-pack/docs/en/security/authentication/configuring-pki-realm.asciidoc

Lines changed: 86 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,15 @@ the desired network layers (transport or http), and map the Distinguished Names
66
(DNs) from the Subject field in the user certificates to roles. You create the
77
mappings in a role mapping file or use the role mappings API.
88

9-
If you want the same users to also be authenticated using certificates when they
10-
connect to {kib}, you must configure the {es} PKI realm to
11-
<<pki-realm-for-proxied-clients,allow delegation>> and to
12-
{kibana-ref}/kibana-authentication.html#pki-authentication[enable PKI authentication in {kib}].
13-
14-
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
1510
example, you can enable SSL/TLS on the transport layer and define a PKI realm to
1611
require transport clients to authenticate with X.509 certificates, while still
17-
authenticating HTTP traffic using username and password credentials. You can
18-
also set `xpack.security.transport.ssl.client_authentication` to `optional` to
19-
allow clients without certificates to authenticate with other credentials.
20-
21-
IMPORTANT: You must enable SSL/TLS with client authentication to use PKI when
22-
clients connect directly to {es}.
12+
authenticating HTTP traffic using username and password credentials.
2313

2414
. Add a realm configuration for a `pki` realm to `elasticsearch.yml` under the
25-
`xpack.security.authc.realms.pki` namespace.
26-
If you are configuring multiple realms, you should
27-
explicitly set the `order` attribute. See <<ref-pki-settings>> for all of the
28-
options you can set for a `pki` realm.
15+
`xpack.security.authc.realms.pki` namespace. If you are configuring multiple
16+
realms, you should explicitly set the `order` attribute. See
17+
<<ref-pki-settings>> for all of the options you can set for a `pki` realm.
2918
+
3019
--
3120
For example, the following snippet shows the most basic `pki` realm configuration:
@@ -44,15 +33,21 @@ xpack:
4433
With this configuration, any certificate trusted by the {es} SSL/TLS layer is
4534
accepted for authentication. The username is the common name (CN) extracted
4635
from the DN in the Subject field of the end-entity certificate. This
47-
configuration does not permit PKI authentication to {kib}.
36+
configuration is not sufficient to permit PKI authentication to {kib};
37+
additional steps are required.
4838

4939
IMPORTANT: When you configure realms in `elasticsearch.yml`, only the
5040
realms you specify are used for authentication. If you also want to use the
5141
`native` or `file` realms, you must include them in the realm chain.
5242

53-
If you want to use something other than the CN of the Subject DN as the
54-
username, you can specify a regex to extract the desired username. The regex is
55-
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
5651
configuration extracts the email address from the Subject DN:
5752

5853
[source, yaml]
@@ -71,6 +66,10 @@ client's certificate, then the realm does not authenticate the certificate.
7166

7267
--
7368

69+
. Optional: If you want the same users to also be authenticated using
70+
certificates when they connect to {kib}, you must configure the {es} PKI realm
71+
to allow delegation. See <<pki-realm-for-proxied-clients>>.
72+
7473
. Restart {es} because realm configuration is not reloaded automatically. If
7574
you're following through with the next steps, you might wish to hold the
7675
restart for last.
@@ -80,6 +79,11 @@ restart for last.
8079
. Enable client authentication on the desired network layers (transport or http).
8180
+
8281
--
82+
IMPORTANT: To use PKI when clients connect directly to {es}, you must enable
83+
SSL/TLS with client authentication. That is to say, you must set `xpack.security.transport.ssl.client_authentication` and
84+
`xpack.security.http.ssl.client_authentication` to `optional` or `required`. If
85+
the setting value is `optional`, clients without certificates can authenticate
86+
with other credentials.
8387

8488
When clients connect directly to {es} and are not proxy-authenticated, the PKI
8589
realm relies on the TLS settings of the node's network interface. The realm can
@@ -95,22 +99,22 @@ In particular this means:
9599
`client_authentication` to `optional` or `required`.
96100
* The interface must _trust_ the certificate that is presented by the client
97101
by configuring either the `truststore` or `certificate_authorities` paths,
98-
or by setting `verification_mode` to `none`. See
99-
<<ssl-tls-settings,`ssl.verification_mode`>> for an explanation of this
100-
setting.
102+
or by setting `verification_mode` to `none`.
101103
* The _protocols_ supported by the interface must be compatible with those
102104
used by the client.
105+
106+
For an explanation of these settings, see <<ssl-tls-settings>>.
103107

104108
The relevant network interface (transport or http) must be configured to trust
105-
any certificate that is to be used within the PKI realm. However, it is possible to
106-
configure the PKI realm to trust only a _subset_ of the certificates accepted
109+
any certificate that is to be used within the PKI realm. However, it is possible
110+
to configure the PKI realm to trust only a _subset_ of the certificates accepted
107111
by the network interface. This is useful when the SSL/TLS layer trusts clients
108112
with certificates that are signed by a different CA than the one that signs your
109113
users' certificates.
110114

111115
To configure the PKI realm with its own truststore, specify the
112116
`truststore.path` option. The path must be located within the Elasticsearch
113-
configuration directory (ES_PATH_CONF). For example:
117+
configuration directory (`ES_PATH_CONF`). For example:
114118

115119
[source, yaml]
116120
------------------------------------------------------------
@@ -135,25 +139,23 @@ xpack.security.authc.realms.pki.pki1.truststore.secure_password
135139
------------------------------------------------------------
136140

137141
The `certificate_authorities` option can be used as an alternative to the
138-
`truststore.path` setting, when the certificate files are PEM formatted
139-
. The setting accepts a list. The two options are exclusive, they cannot be both used
142+
`truststore.path` setting, when the certificate files are PEM formatted. The
143+
setting accepts a list. The two options are exclusive, they cannot be both used
140144
simultaneously.
141145
--
142146

143147
. Map roles for PKI users.
144148
+
145149
--
146-
You map roles for PKI users through the <<security-role-mapping-apis,role
147-
mapping APIs>> or by using a file stored on each node. Both configuration
148-
options are merged together. When a user authenticates against a PKI realm, the
149-
privileges for that user are the union of all privileges defined by the roles
150-
to which the user is mapped.
150+
You map roles for PKI users through the
151+
<<security-role-mapping-apis,role mapping APIs>> or by using a file stored on
152+
each node. Both configuration options are merged together. When a user
153+
authenticates against a PKI realm, the privileges for that user are the union of
154+
all privileges defined by the roles to which the user is mapped.
151155

152156
You identify a user by the distinguished name in their certificate.
153157
For example, the following mapping configuration maps `John Doe` to the
154-
`user` role:
155-
156-
Using the role-mapping API:
158+
`user` role using the role mapping API:
157159

158160
[source,console]
159161
--------------------------------------------------
@@ -169,10 +171,7 @@ PUT /_security/role_mapping/users
169171

170172
<1> The distinguished name (DN) of a PKI user.
171173

172-
Or, alternatively, configured inside a role-mapping file. The file's path
173-
defaults to `ES_PATH_CONF/role_mapping.yml`. You can specify a different path (which must be within
174-
ES_PATH_CONF) by using the `files.role_mapping` realm setting (e.g.
175-
`xpack.security.authc.realms.pki.pki1.files.role_mapping`):
174+
Alternatively, use a role-mapping file. For example:
176175

177176
[source, yaml]
178177
------------------------------------------------------------
@@ -182,9 +181,14 @@ user: <1>
182181
<1> The name of a role.
183182
<2> The distinguished name (DN) of a PKI user.
184183

184+
The file's path defaults to `ES_PATH_CONF/role_mapping.yml`. You can specify a
185+
different path (which must be within `ES_PATH_CONF`) by using the
186+
`files.role_mapping` realm setting (e.g.
187+
`xpack.security.authc.realms.pki.pki1.files.role_mapping`).
188+
185189
The distinguished name for a PKI user follows X.500 naming conventions which
186190
place the most specific fields (like `cn` or `uid`) at the beginning of the
187-
name, and the most general fields (like `o` or `dc`) at the end of the name.
191+
name and the most general fields (like `o` or `dc`) at the end of the name.
188192
Some tools, such as _openssl_, may print out the subject name in a different
189193
format.
190194

@@ -206,47 +210,60 @@ alternative to role mapping.
206210

207211
By default, the PKI realm relies on the node's network interface to perform the
208212
SSL/TLS handshake and extract the client certificate. This behaviour requires
209-
that that clients connect directly to {es} so that their SSL connection is
210-
terminated by the {es} node. If SSL/TLS authenticatication is to be performed
211-
by {kib}, the PKI realm must be configured to permit delegation.
213+
that clients connect directly to {es} so that their SSL connection is terminated
214+
by the {es} node. If SSL/TLS authentication is to be performed by {kib}, the
215+
PKI realm must be configured to permit delegation.
212216

213217
Specifically, when clients presenting X.509 certificates connect to {kib},
214218
{kib} performs the SSL/TLS authentication. {kib} then forwards the client's
215-
certificate chain, by calling an {es} API, to have them further validated by
219+
certificate chain (by calling an {es} API) to have them further validated by
216220
the PKI realms that have been configured for delegation.
217221

218222
To permit authentication delegation for a specific {es} PKI realm, start by
219223
configuring the realm for the usual case, as detailed in the
220-
<<pki-realm-for-direct-clients>>
221-
section. Note that you must explicitly configure a `truststore` (or,
222-
equivalently `certificate_authorities`) even though it is the same trust
223-
configuration that you have configured on the network layer. Afterwards,
224-
simply toggle the `delegation.enabled` realm setting to `true`. This realm is
225-
now allowed to validate delegated PKI authentication (after restarting {es}).
224+
<<pki-realm-for-direct-clients>> section. In this scenario, when you enable TLS,
225+
it is mandatory that you <<tls-http,encrypt HTTP client communications>>.
226226

227-
NOTE: PKI authentication delegation requires that the
228-
`xpack.security.authc.token.enabled` setting be `true` and that SSL/TLS be
229-
configured (without SSL/TLS client authentication).
227+
You must also explicitly configure a `truststore` (or, equivalently
228+
`certificate_authorities`) even though it is the same trust configuration that
229+
you have configured on the network layer. The
230+
`xpack.security.authc.token.enabled` and `delegation.enabled` settings must also
231+
be `true`. For example:
232+
233+
[source, yaml]
234+
------------------------------------------------------------
235+
xpack:
236+
security:
237+
authc:
238+
token.enabled: true
239+
realms:
240+
pki:
241+
pki1:
242+
order: 1
243+
delegation.enabled: true
244+
truststore:
245+
path: "pki1_truststore.jks"
246+
------------------------------------------------------------
230247

231-
NOTE: {kib} also needs to be
232-
{kibana-ref}/kibana-authentication.html#pki-authentication[configured to allow
233-
PKI certificate authentication].
248+
After you restart {es}, this realm can validate delegated PKI authentication.
249+
You must then
250+
{kibana-ref}/kibana-authentication.html#pki-authentication[configure {kib} to allow PKI certificate authentication].
234251

235252
A PKI realm with `delegation.enabled` still works unchanged for clients
236-
connecting directly to {es}. Directly authenticated users, and users that are PKI
253+
connecting directly to {es}. Directly authenticated users and users that are PKI
237254
authenticated by delegation to {kib} both follow the same
238255
<<mapping-roles,role mapping rules>> or
239256
<<authorization_realms,authorization realms configurations>>.
240257

241-
However, if you use the <<security-role-mapping-apis,role mapping APIs>>,
242-
you can distinguish between users that are authenticated by delegation and
243-
users that are authenticated directly. The former have the
244-
extra fields `pki_delegated_by_user` and `pki_delegated_by_realm` in the user's
245-
metadata. In the common setup, where authentication is delegated to {kib}, the
246-
values of these fields are `kibana` and `reserved`, respectively. For example,
247-
the following role mapping rule will assign the `role_for_pki1_direct` role to
248-
all users that have been authenticated directly by the `pki1` realm, by
249-
connecting to {es} instead of going through {kib}:
258+
If you use the <<security-role-mapping-apis,role mapping APIs>>, however, you
259+
can distinguish between users that are authenticated by delegation and users
260+
that are authenticated directly. The former have the extra fields
261+
`pki_delegated_by_user` and `pki_delegated_by_realm` in the user's metadata. In
262+
the common setup, where authentication is delegated to {kib}, the values of
263+
these fields are `kibana` and `reserved`, respectively. For example, the
264+
following role mapping rule assigns the `role_for_pki1_direct` role to all users
265+
that have been authenticated directly by the `pki1` realm, by connecting to {es}
266+
instead of going through {kib}:
250267

251268
[source,console]
252269
--------------------------------------------------
@@ -269,5 +286,5 @@ PUT /_security/role_mapping/direct_pki_only
269286
}
270287
--------------------------------------------------
271288

272-
<1> only when this metadata field is set (it is *not* `null`) the user has been
273-
authenticated in the delegation scenario.
289+
<1> If this metadata field is set (that is to say, it is *not* `null`), the user
290+
has been authenticated in the delegation scenario.

x-pack/docs/en/security/authentication/pki-realm.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
=== PKI user authentication
44

55
You can configure {es} to use Public Key Infrastructure (PKI) certificates to
6-
authenticate users. This requires clients connecting directly to {es} to
7-
present X.509 certificates. The certificates must first be accepted for
8-
authentication on the SSL/TLS layer on {es}. Only then they are optionally
6+
authenticate users. In this scenario, clients connecting directly to {es} must
7+
present X.509 certificates. First, the certificates must be accepted for
8+
authentication on the SSL/TLS layer on {es}. Then they are optionally
99
further validated by a PKI realm. See <<pki-realm-for-direct-clients>>.
1010

1111
You can also use PKI certificates to authenticate to {kib}, however this

0 commit comments

Comments
 (0)