oidc-authenticate-api.asciidoc 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. [role="xpack"]
  2. [[security-api-oidc-authenticate]]
  3. === OpenID Connect authenticate API
  4. ++++
  5. <titleabbrev>OpenID Connect 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 the response to an oAuth 2.0 authentication request for consumption from
  13. {es}. Upon successful validation, {es} will respond with an {es} internal Access
  14. Token and Refresh Token that can be subsequently used for authentication.
  15. [[security-api-oidc-authenticate-request]]
  16. ==== {api-request-title}
  17. `POST /_security/oidc/authenticate`
  18. //[[security-api-oidc-authenticate-prereqs]]
  19. //==== {api-prereq-title}
  20. [[security-api-oidc-authenticate-desc]]
  21. ==== {api-description-title}
  22. This API endpoint basically exchanges successful OpenID Connect Authentication
  23. responses for {es} access and refresh tokens to be used for authentication.
  24. {es} exposes all the necessary OpenID Connect related functionality via the
  25. OpenID Connect APIs. These APIs are used internally by {kib} in order to provide
  26. OpenID Connect based authentication, but can also be used by other, custom web
  27. applications or other clients. See also
  28. <<security-api-oidc-prepare-authentication,OpenID Connect prepare authentication API>>
  29. and <<security-api-oidc-logout,OpenID Connect logout API>>
  30. [[security-api-oidc-authenticate-request-body]]
  31. ==== {api-request-body-title}
  32. `redirect_uri`::
  33. (Required, string) The URL to which the OpenID Connect Provider redirected the User Agent in
  34. response to an authentication request, after a successful authentication. This
  35. URL is expected to be provided as-is (URL encoded), taken from the body of the
  36. response or as the value of a `Location` header in the response from the OpenID
  37. Connect Provider.
  38. `state`::
  39. (Required, string) Used to maintain state between the authentication request and the
  40. response. This value needs to be the same as the one that was provided to the
  41. call to `/_security/oidc/prepare` earlier, or the one that was generated by {es}
  42. and included in the response to that call.
  43. `nonce`::
  44. (Required, string) Used to associate a Client session with an ID Token and to mitigate
  45. replay attacks. This value needs to be the same as the one that was provided to
  46. the call to `/_security/oidc/prepare` earlier, or the one that was generated by
  47. {es} and included in the response to that call.
  48. `realm`::
  49. (Optional, string) Used to identify the name of the OpenID Connect realm that should
  50. be used to authenticate this. Useful when multiple realms have been defined.
  51. [[security-api-oidc-authenticate-example]]
  52. ==== {api-examples-title}
  53. The following example request exchanges the response that was returned from the
  54. OpenID Connect Provider after a successful authentication, for an {es} access
  55. token and refresh token to be used in subsequent requests. This example is from
  56. an authentication that uses the authorization code grant flow.
  57. [source,console]
  58. --------------------------------------------------
  59. POST /_security/oidc/authenticate
  60. {
  61. "redirect_uri" : "https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
  62. "state" : "4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I",
  63. "nonce" : "WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM",
  64. "realm" : "oidc1"
  65. }
  66. --------------------------------------------------
  67. // TEST[catch:unauthorized]
  68. The following example output contains the access token that was generated in
  69. response, the amount of time (in seconds) that the token expires in, the type,
  70. and the refresh token:
  71. [source,js]
  72. --------------------------------------------------
  73. {
  74. "access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
  75. "type" : "Bearer",
  76. "expires_in" : 1200,
  77. "refresh_token": "vLBPvmAB6KvwvJZr27cS"
  78. }
  79. --------------------------------------------------
  80. // NOTCONSOLE