delegate-pki-authentication.asciidoc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. [role="xpack"]
  2. [[security-api-delegate-pki-authentication]]
  3. === Delegate PKI authentication API
  4. ++++
  5. <titleabbrev>Delegate PKI authentication</titleabbrev>
  6. ++++
  7. Implements the exchange of an {@code X509Certificate} chain into an {es} access
  8. token.
  9. [[security-api-delegate-pki-authentication-request]]
  10. ==== {api-request-title}
  11. `POST /_security/delegate_pki`
  12. [[security-api-delegate-pki-authentication-prereqs]]
  13. ==== {api-prereq-title}
  14. * To call this API, the (proxy) user must have the `delegate_pki` or the `all`
  15. cluster privilege. The `kibana_system` built-in role already grants this
  16. privilege. See {stack-ov}/security-privileges.html[Security privileges].
  17. [[security-api-delegate-pki-authentication-desc]]
  18. ==== {api-description-title}
  19. This API implements the exchange of an _X509Certificate_ chain for an {es}
  20. access token. The certificate chain is validated, according to RFC 5280, by
  21. sequentially considering the trust configuration of every installed PKI realm
  22. that has `delegation.enabled` set to `true` (default is `false`). A
  23. successfully trusted client certificate is also subject to the validation of
  24. the subject distinguished name according to that respective's realm
  25. `username_pattern`.
  26. This API is called by *smart* and *trusted* proxies, such as {kib}, which
  27. terminate the user's TLS session but still want to authenticate the user
  28. by using a PKI realm--as if the user connected directly to {es}. For more
  29. details, see <<pki-realm-for-proxied-clients>>.
  30. IMPORTANT: The association between the subject public key in the target
  31. certificate and the corresponding private key is *not* validated. This is part
  32. of the TLS authentication process and it is delegated to the proxy that calls
  33. this API. The proxy is *trusted* to have performed the TLS authentication and
  34. this API translates that authentication into an {es} access token.
  35. [[security-api-delegate-pki-authentication-request-body]]
  36. ==== {api-request-body-title}
  37. `x509_certificate_chain`::
  38. (Required, list of strings) The _X509Certificate_ chain, which is represented as
  39. an ordered string array. Each string in the array is a base64-encoded
  40. (Section 4 of RFC4648 - not base64url-encoded) of the certificate's DER encoding.
  41. +
  42. The first element is the target certificate contains the subject distinguished
  43. name that is requesting access. This may be followed by additional certificates;
  44. each subsequent certificate is used to certify the previous one.
  45. [[security-api-delegate-pki-authentication-response-body]]
  46. ==== {api-response-body-title}
  47. `access_token`::
  48. (string) An access token associated to the subject distinguished name of the
  49. client's certificate.
  50. `expires_in`::
  51. (time units) The amount of time (in seconds) that the token expires in.
  52. `type`::
  53. (string) The type of token.
  54. [[security-api-delegate-pki-authentication-example]]
  55. ==== {api-examples-title}
  56. The following is an example request:
  57. [source, js]
  58. ------------------------------------------------------------
  59. POST /_security/delegate_pki
  60. {
  61. "x509_certificate_chain": ["MIIDbTCCAlWgAwIBAgIJAIxTS7Qdho9jMA0GCSqGSIb3DQEBCwUAMFMxKzApBgNVBAMTIkVsYXN0aWNzZWFyY2ggVGVzdCBJbnRlcm1lZGlhdGUgQ0ExFjAUBgNVBAsTDUVsYXN0aWNzZWFyY2gxDDAKBgNVBAoTA29yZzAeFw0xOTA3MTkxMzMzNDFaFw0yMzA3MTgxMzMzNDFaMEoxIjAgBgNVBAMTGUVsYXN0aWNzZWFyY2ggVGVzdCBDbGllbnQxFjAUBgNVBAsTDUVsYXN0aWNzZWFyY2gxDDAKBgNVBAoTA29yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANHgMX2aX8t0nj4sGLNuKISmmXIYCj9RwRqS7L03l9Nng7kOKnhHu/nXDt7zMRJyHj+q6FAt5khlavYSVCQyrDybRuA5z31gOdqXerrjs2OXS5HSHNvoDAnHFsaYX/5geMewVTtc/vqpd7Ph/QtaKfmG2FK0JNQo0k24tcgCIcyMtBh6BA70yGBM0OT8GdOgd/d/mA7mRhaxIUMNYQzRYRsp4hMnnWoOTkR5Q8KSO3MKw9dPSpPe8EnwtJE10S3s5aXmgytru/xQqrFycPBNj4KbKVmqMP0G60CzXik5pr2LNvOFz3Qb6sYJtqeZF+JKgGWdaTC89m63+TEnUHqk0lcCAwEAAaNNMEswCQYDVR0TBAIwADAdBgNVHQ4EFgQU/+aAD6Q4mFq1vpHorC25/OY5zjcwHwYDVR0jBBgwFoAU8siFCiMiYZZm/95qFC75AG/LRE0wDQYJKoZIhvcNAQELBQADggEBAIRpCgDLpvXcgDHUk10uhxev21mlIbU+VP46ANnCuj0UELhTrdTuWvO1PAI4z+WbDUxryQfOOXO9R6D0dE5yR56L/J7d+KayW34zU7yRDZM7+rXpocdQ1Ex8mjP9HJ/Bf56YZTBQJpXeDrKow4FvtkI3bcIMkqmbG16LHQXeG3RS4ds4S4wCnE2nA6vIn9y+4R999q6y1VSBORrYULcDWxS54plHLEdiMr1vVallg82AGobS9GMcTL2U4Nx5IYZG7sbTk3LrDxVpVg/S2wLofEdOEwqCeHug/iOihNLJBabEW6z4TDLJAVW5KCY1DfhkYlBfHn7vxKkfKoCUK/yLWWI="] <1>
  62. }
  63. ------------------------------------------------------------
  64. // CONSOLE
  65. <1> A one element certificate chain.
  66. Which returns the following response:
  67. [source,js]
  68. --------------------------------------------------
  69. {
  70. "access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
  71. "type" : "Bearer",
  72. "expires_in" : 1200
  73. }
  74. --------------------------------------------------
  75. // TESTRESPONSE[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]