oidc-authenticate-api.asciidoc 3.7 KB

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