saml-authenticate-api.asciidoc 3.7 KB

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