Skip to content

Commit 79d2e1e

Browse files
authored
[DOCS] Adds PKI delegation.enabled example (#53030)
1 parent 38ecfab commit 79d2e1e

File tree

2 files changed

+91
-71
lines changed

2 files changed

+91
-71
lines changed

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

Lines changed: 88 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,18 @@
33

44
To use PKI in {es}, you configure a PKI realm, enable client authentication on
55
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.
78

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
1310
example, you can enable SSL/TLS on the transport layer and define a PKI realm to
1411
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.
2113

2214
. 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.
2618
+
2719
--
2820
For example, the following snippet shows the most basic `pki` realm configuration:
@@ -41,15 +33,21 @@ xpack:
4133
With this configuration, any certificate trusted by the {es} SSL/TLS layer is
4234
accepted for authentication. The username is the common name (CN) extracted
4335
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.
4538

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

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
5351
configuration extracts the email address from the Subject DN:
5452

5553
[source, yaml]
@@ -69,6 +67,10 @@ client's certificate, then the realm does not authenticate the certificate.
6967

7068
--
7169

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+
7274
. Restart {es} because realm configuration is not reloaded automatically. If
7375
you're following through with the next steps, you might wish to hold the
7476
restart for last.
@@ -78,6 +80,11 @@ restart for last.
7880
. Enable client authentication on the desired network layers (transport or http).
7981
+
8082
--
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.
8188

8289
When clients connect directly to {es} and are not proxy-authenticated, the PKI
8390
realm relies on the TLS settings of the node's network interface. The realm can
@@ -93,22 +100,22 @@ In particular this means:
93100
`client_authentication` to `optional` or `required`.
94101
* The interface must _trust_ the certificate that is presented by the client
95102
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`.
99104
* The _protocols_ supported by the interface must be compatible with those
100105
used by the client.
106+
107+
For an explanation of these settings, see <<ssl-tls-settings>>.
101108

102109
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
105112
by the network interface. This is useful when the SSL/TLS layer trusts clients
106113
with certificates that are signed by a different CA than the one that signs your
107114
users' certificates.
108115

109116
To configure the PKI realm with its own truststore, specify the
110117
`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:
112119

113120
[source, yaml]
114121
------------------------------------------------------------
@@ -134,25 +141,23 @@ xpack.security.authc.realms.pki.pki1.truststore.secure_password
134141
------------------------------------------------------------
135142

136143
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
139146
simultaneously.
140147
--
141148

142149
. Map roles for PKI users.
143150
+
144151
--
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.
150157

151158
You identify a user by the distinguished name in their certificate.
152159
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:
156161

157162
[source,console]
158163
--------------------------------------------------
@@ -168,10 +173,7 @@ PUT /_security/role_mapping/users
168173

169174
<1> The distinguished name (DN) of a PKI user.
170175

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:
175177

176178
[source, yaml]
177179
------------------------------------------------------------
@@ -181,9 +183,14 @@ user: <1>
181183
<1> The name of a role.
182184
<2> The distinguished name (DN) of a PKI user.
183185

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+
184191
The distinguished name for a PKI user follows X.500 naming conventions which
185192
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.
187194
Some tools, such as _openssl_, may print out the subject name in a different
188195
format.
189196

@@ -205,47 +212,60 @@ alternative to role mapping.
205212

206213
By default, the PKI realm relies on the node's network interface to perform the
207214
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.
211218

212219
Specifically, when clients presenting X.509 certificates connect to {kib},
213220
{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
215222
the PKI realms that have been configured for delegation.
216223

217224
To permit authentication delegation for a specific {es} PKI realm, start by
218225
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>>.
225228

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+
------------------------------------------------------------
229249

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].
233253

234254
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
236256
authenticated by delegation to {kib} both follow the same
237257
<<mapping-roles,role mapping rules>> or
238258
<<authorization_realms,authorization realms configurations>>.
239259

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}:
249269

250270
[source,console]
251271
--------------------------------------------------
@@ -268,5 +288,5 @@ PUT /_security/role_mapping/direct_pki_only
268288
}
269289
--------------------------------------------------
270290

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.

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)