saml-authenticate-api.asciidoc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [role="xpack"]
  2. [[security-api-saml-authenticate]]
  3. === SAML authenticate API
  4. Submits a SAML `Response` message to {es} for consumption.
  5. NOTE: This API is intended for use by custom web applications other than {kib}.
  6. If you are using {kib}, see the <<saml-guide>>.
  7. [[security-api-saml-authenticate-request]]
  8. ==== {api-request-title}
  9. `POST /_security/saml/authenticate`
  10. [[security-api-saml-authenticate-desc]]
  11. ==== {api-description-title}
  12. The SAML message that is submitted can be:
  13. * a response to a SAML authentication request that was previously created using the
  14. <<security-api-saml-prepare-authentication, SAML prepare authentication API>>.
  15. * an unsolicited SAML message in the case of an IdP-initiated single sign-on (SSO) flow.
  16. In either cases, the SAML message needs to be a base64 encoded XML document with a root
  17. element of `<Response>`
  18. After successful validation, {es} responds with an
  19. {es} internal access token and refresh token that can be subsequently used for authentication.
  20. This API endpoint essentially exchanges SAML responses that
  21. indicate successful authentication in the IdP for {es} access and refresh tokens,
  22. which can be used for authentication against {es}.
  23. {es} exposes all the necessary SAML related functionality via the SAML APIs.
  24. These APIs are used internally by {kib} in order to provide SAML based
  25. authentication, but can also be used by other, custom web applications or other
  26. clients. See also
  27. <<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
  28. <<security-api-saml-invalidate,SAML invalidate API>> and
  29. <<security-api-saml-logout,SAML logout API>>.
  30. [[security-api-saml-authenticate-request-body]]
  31. ==== {api-request-body-title}
  32. `content`::
  33. (Required, string) The SAML response as it was sent by the user's browser, usually a
  34. Base64 encoded XML document.
  35. `ids`::
  36. (Required, array) A json array with all the valid SAML Request Ids that the caller of
  37. the API has for the current user.
  38. [[security-api-saml-authenticate-response-body]]
  39. ==== {api-response-body-title}
  40. `access_token`::
  41. (string) The access token that was generated by {es}.
  42. `username`::
  43. (string) The authenticated user's name.
  44. `expires_in`::
  45. (integer) The amount of time (in seconds) left until the token expires.
  46. `refresh_token`::
  47. (string) The refresh token that was generated by {es}.
  48. [[security-api-saml-authenticate-example]]
  49. ==== {api-examples-title}
  50. The following example exchanges a SAML Response indicating a successful
  51. authentication at the SAML IdP for an {es} access token and refresh token to be
  52. used in subsequent requests:
  53. [source,console]
  54. --------------------------------------------------
  55. POST /_security/saml/authenticate
  56. {
  57. "content" : "PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....",
  58. "ids" : ["4fee3b046395c4e751011e97f8900b5273d56685"]
  59. }
  60. --------------------------------------------------
  61. // TEST[skip:handled in IT]
  62. The API returns the following response:
  63. [source,js]
  64. --------------------------------------------------
  65. {
  66. "access_token" : "46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3",
  67. "username" : "Bearer",
  68. "expires_in" : 1200,
  69. "refresh_token": "mJdXLtmvTUSpoLwMvdBt_w"
  70. }
  71. --------------------------------------------------
  72. // NOTCONSOLE