saml-authenticate-api.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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-stack>>.
  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>>,
  32. <<security-api-saml-logout,SAML logout API>>, and
  33. <<security-api-saml-complete-logout, SAML complete logout API>>.
  34. [[security-api-saml-authenticate-request-body]]
  35. ==== {api-request-body-title}
  36. `content`::
  37. (Required, string) The SAML response as it was sent by the user's browser, usually a
  38. Base64 encoded XML document.
  39. `ids`::
  40. (Required, array) A json array with all the valid SAML Request Ids that the caller of
  41. the API has for the current user.
  42. `realm`::
  43. (Optional, string) The name of the realm that should authenticate the SAML response.
  44. Useful in cases where many SAML realms are defined.
  45. [[security-api-saml-authenticate-response-body]]
  46. ==== {api-response-body-title}
  47. `access_token`::
  48. (string) The access token that was generated by {es}.
  49. `username`::
  50. (string) The authenticated user's name.
  51. `expires_in`::
  52. (integer) The amount of time (in seconds) left until the token expires.
  53. `refresh_token`::
  54. (string) The refresh token that was generated by {es}.
  55. `realm`::
  56. (string) The name of the realm that the user was authenticated by.
  57. [[security-api-saml-authenticate-example]]
  58. ==== {api-examples-title}
  59. The following example exchanges a SAML Response indicating a successful
  60. authentication at the SAML IdP for an {es} access token and refresh token to be
  61. used in subsequent requests:
  62. [source,console]
  63. --------------------------------------------------
  64. POST /_security/saml/authenticate
  65. {
  66. "content" : "PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....",
  67. "ids" : ["4fee3b046395c4e751011e97f8900b5273d56685"]
  68. }
  69. --------------------------------------------------
  70. // TEST[skip:handled in IT]
  71. The API returns the following response:
  72. [source,js]
  73. --------------------------------------------------
  74. {
  75. "access_token" : "46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3",
  76. "username" : "Bearer",
  77. "expires_in" : 1200,
  78. "refresh_token": "mJdXLtmvTUSpoLwMvdBt_w",
  79. "realm": "saml1"
  80. }
  81. --------------------------------------------------
  82. // NOTCONSOLE