oidc-authenticate-api.asciidoc 3.5 KB

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