PKI User Authentication
editPKI User Authentication [1.3.0] Added in 1.3.0.
editYou can configure Shield to use Public Key Infrastructure (PKI) certificates to authenticate users. This requires clients to present X.509 certificates. To use PKI, you configure a PKI realm, enable client authentication on the desired network layers (transport or http), and map the DNs from the user certificates to Shield roles in the role mapping file.
You can use a combination of PKI encryption and username and password authentication. For example,
you can enable SSL/TLS on the transport layer and define a PKI realm to require transport clients to
authenticate with X.509 certificates, while still authenticating HTTP traffic using usernames and
passwords. You can also set shield.transport.ssl.client.auth
to optional
to allow clients without certificates to authenticate with other credentials.
You must enable SSL/TLS to use PKI. For more information, see Setting Up SSL/TLS on a Cluster.
PKI Realm Configuration
editLike realms, you configure options for a pki
realm in the shield.authc.realms
namespace in
elasticsearch.yml
.
To configure PKI realm:
-
Add a realm configuration of type
pki
toelasticsearch.yml
in theshield.authc.realms
namespace. At a minimum, you must set the realmtype
topki
. If you are configuring multiple realms, you should also explicitly set theorder
attribute. See PKI Realm Settings for all of the options you can set for anpki
realm.For example, the following snippet shows the most basic PKI realm configuration:
shield: authc: realms: pki1: type: pki
With this configuration, any certificate trusted by the SSL/TLS layer is accepted for authentication. The username is the common name (CN) extracted from the DN of the certificate.
If you want to use something other than the CN of the DN as the username, you can specify a regex to extract the desired username. For example, the regex in the following configuration extracts the email address from the DN:
shield: authc: realms: pki1: type: pki username_pattern: "EMAILADDRESS=(.*?)(?:,|$)"
You can also specify which truststore to use for authentication. This is useful when the SSL/TLS layer trusts clients with certificates that are signed by a different CA than the one that signs your users' certificates. To specify the location of the truststore, specify the
truststore.path
option:shield: authc: realms: pki1: type: pki truststore: path: "/path/to/pki_truststore.jks" password: "changeme"
- Restart Elasticsearch.
PKI Realm Settings
editSetting |
Required |
Description |
|
yes |
Indicates the realm type. Must be set to |
|
no |
Indicates the priority of this realm within the realm
chain. Realms with a lower order are consulted first.
Although not required, we recommend explicitly
setting this value when you configure multiple realms.
Defaults to |
|
no |
Indicates whether this realm is enabled or disabled.
Enables you to disable a realm without removing its
configuration. Defaults to |
|
no |
Specifies the regular expression pattern used to extract
the username from the certificate DN. The first match
group is used as the username. Defaults to
|
|
no |
The path to the truststore. Defaults to the path defined by SSL/TLS settings. |
|
no |
Specifies the password for the truststore. Must be
provided if |
|
no |
Specifies the algorithm used for the truststore. Defaults to
|
|
no |
Specifies the location
for the YAML role mapping
configuration file. Defaults to
|
Assigning Roles for PKI Users
editYou assign roles for PKI users in the role mapping file stored on each node. You identify a user
by the distinguished name in their certificate. For example, the following mapping
configuration assigns John Doe
the user
role:
The name of a Shield role defined in the roles file |
|
The distinguished name of a PKI user. |
For more information, see Mapping Users and Groups to Roles.