delegate-pki-authentication.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. [role="xpack"]
  2. [[security-api-delegate-pki-authentication]]
  3. === Delegate PKI authentication API
  4. ++++
  5. <titleabbrev>Delegate PKI authentication</titleabbrev>
  6. ++++
  7. .New API reference
  8. [sidebar]
  9. --
  10. For the most up-to-date API details, refer to {api-es}/group/endpoint-security[Security APIs].
  11. --
  12. Implements the exchange of an _X509Certificate_ chain into an {es} access
  13. token.
  14. [[security-api-delegate-pki-authentication-request]]
  15. ==== {api-request-title}
  16. `POST /_security/delegate_pki`
  17. [[security-api-delegate-pki-authentication-prereqs]]
  18. ==== {api-prereq-title}
  19. * To call this API, the (proxy) user must have the `delegate_pki` or the `all`
  20. cluster privilege. The `kibana_system` built-in role already grants this
  21. privilege. See <<security-privileges>>.
  22. [[security-api-delegate-pki-authentication-desc]]
  23. ==== {api-description-title}
  24. This API implements the exchange of an _X509Certificate_ chain for an {es}
  25. access token. The certificate chain is validated, according to RFC 5280, by
  26. sequentially considering the trust configuration of every installed PKI realm
  27. that has `delegation.enabled` set to `true` (default is `false`). A
  28. successfully trusted client certificate is also subject to the validation of
  29. the subject distinguished name according to that respective's realm
  30. `username_pattern`.
  31. This API is called by *smart* and *trusted* proxies, such as {kib}, which
  32. terminate the user's TLS session but still want to authenticate the user
  33. by using a PKI realm--as if the user connected directly to {es}. For more
  34. details, see <<pki-realm-for-proxied-clients>>.
  35. IMPORTANT: The association between the subject public key in the target
  36. certificate and the corresponding private key is *not* validated. This is part
  37. of the TLS authentication process and it is delegated to the proxy that calls
  38. this API. The proxy is *trusted* to have performed the TLS authentication and
  39. this API translates that authentication into an {es} access token.
  40. [[security-api-delegate-pki-authentication-request-body]]
  41. ==== {api-request-body-title}
  42. `x509_certificate_chain`::
  43. (Required, list of strings) The _X509Certificate_ chain, which is represented as
  44. an ordered string array. Each string in the array is a base64-encoded
  45. (Section 4 of RFC4648 - not base64url-encoded) of the certificate's DER encoding.
  46. +
  47. The first element is the target certificate contains the subject distinguished
  48. name that is requesting access. This may be followed by additional certificates;
  49. each subsequent certificate is used to certify the previous one.
  50. [[security-api-delegate-pki-authentication-response-body]]
  51. ==== {api-response-body-title}
  52. `access_token`::
  53. (string) An access token associated to the subject distinguished name of the
  54. client's certificate.
  55. `expires_in`::
  56. (time units) The amount of time (in seconds) that the token expires in.
  57. `type`::
  58. (string) The type of token.
  59. [[security-api-delegate-pki-authentication-example]]
  60. ==== {api-examples-title}
  61. The following is an example request:
  62. [source,console]
  63. ------------------------------------------------------------
  64. POST /_security/delegate_pki
  65. {
  66. "x509_certificate_chain": ["MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g=="] <1>
  67. }
  68. ------------------------------------------------------------
  69. <1> A one element certificate chain.
  70. Which returns the following response:
  71. [source,console-result]
  72. --------------------------------------------------
  73. {
  74. "access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
  75. "type" : "Bearer",
  76. "expires_in" : 1200,
  77. "authentication" : {
  78. "username" : "Elasticsearch Test Client",
  79. "roles" : [ ],
  80. "full_name" : null,
  81. "email" : null,
  82. "metadata" : {
  83. "pki_dn" : "O=org, OU=Elasticsearch, CN=Elasticsearch Test Client",
  84. "pki_delegated_by_user" : "test_admin",
  85. "pki_delegated_by_realm" : "file"
  86. },
  87. "enabled" : true,
  88. "authentication_realm" : {
  89. "name" : "pki1",
  90. "type" : "pki"
  91. },
  92. "lookup_realm" : {
  93. "name" : "pki1",
  94. "type" : "pki"
  95. },
  96. "authentication_type" : "realm"
  97. }
  98. }
  99. --------------------------------------------------
  100. // TESTRESPONSE[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]