saml-authenticate-api.asciidoc 3.5 KB

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