| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | --:api: delegate-pki:request: DelegatePkiAuthenticationRequest:response: DelegatePkiAuthenticationResponse--[role="xpack"][id="{upid}-{api}"]=== Delegate PKI Authentication APIThis API is called by *smart* proxies to Elasticsearch, such as Kibana, thatterminate the user's TLS session but that still wish to authenticate the useron the Elasticsearch side using a PKI realm, which normally requires users toauthenticate over TLS directly to Elasticsearch. It implements the exchange ofthe client's {@code X509Certificate} chain from the TLS authentication into anElasticsearch access token.IMPORTANT: The association between the subject public key in the targetcertificate and the corresponding private key is *not* validated. This is partof the TLS authentication process and it is delegated to the proxy calling thisAPI. The proxy is *trusted* to have performed the TLS authentication, and thisAPI translates that authentication into an Elasticsearch access token.[id="{upid}-{api}-request"]==== Delegate PKI Authentication RequestThe request contains the client's {@code X509Certificate} chain. Thecertificate chain is represented as a list where the first element is thetarget certificate containing the subject distinguished name that is requestingaccess. This may be followed by additional certificates, with each subsequentcertificate being the one used to certify the previous one. The certificatechain is validated according to RFC 5280, by sequentially considering the trustconfiguration of every installed {@code PkiRealm} that has {@codePkiRealmSettings#DELEGATION_ENABLED_SETTING} set to {@code true} (default is{@code false}). A successfully trusted target certificate is also subject tothe validation of the subject distinguished name according to that respective'srealm {@code PkiRealmSettings#USERNAME_PATTERN_SETTING}.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SecurityDocumentationIT.java[delegate-pki-request]--------------------------------------------------include::../execution.asciidoc[][id="{upid}-{api}-response"]==== Delegate PKI Authentication ResponseThe returned +{response}+ contains the following properties:`accessToken`:: This is the newly created access token.   It can be used to authenticate to the Elasticsearch cluster.`type`:: The type of the token, this is always `"Bearer"`.`expiresIn`:: The length of time (in seconds) until the token will expire.   The token will be considered invalid after that time.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests}/SecurityDocumentationIT.java[delegate-pki-response]--------------------------------------------------<1> The `accessToken` can be used to authentication to Elasticsearch.
 |