delegate-pki-authentication.asciidoc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 _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 <<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,console]
  58. ------------------------------------------------------------
  59. POST /_security/delegate_pki
  60. {
  61. "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>
  62. }
  63. ------------------------------------------------------------
  64. <1> A one element certificate chain.
  65. Which returns the following response:
  66. [source,console-result]
  67. --------------------------------------------------
  68. {
  69. "access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
  70. "type" : "Bearer",
  71. "expires_in" : 1200,
  72. "authentication" : {
  73. "username" : "Elasticsearch Test Client",
  74. "roles" : [ ],
  75. "full_name" : null,
  76. "email" : null,
  77. "metadata" : {
  78. "pki_dn" : "O=org, OU=Elasticsearch, CN=Elasticsearch Test Client",
  79. "pki_delegated_by_user" : "test_admin",
  80. "pki_delegated_by_realm" : "file"
  81. },
  82. "enabled" : true,
  83. "authentication_realm" : {
  84. "name" : "pki1",
  85. "type" : "pki"
  86. },
  87. "lookup_realm" : {
  88. "name" : "pki1",
  89. "type" : "pki"
  90. },
  91. "authentication_type" : "realm"
  92. }
  93. }
  94. --------------------------------------------------
  95. // TESTRESPONSE[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]