authenticate.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [role="xpack"]
  2. [[security-api-authenticate]]
  3. === Authenticate API
  4. ++++
  5. <titleabbrev>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. Enables you to submit a request with a basic auth header to
  13. authenticate a user and retrieve information about the authenticated user.
  14. [[security-api-authenticate-request]]
  15. ==== {api-request-title}
  16. `GET /_security/_authenticate`
  17. [[security-api-authenticate-desc]]
  18. ==== {api-description-title}
  19. A successful call returns a JSON structure that shows user information such as their username, the roles that are
  20. assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
  21. [[security-api-authenticate-response-codes]]
  22. ==== {api-response-codes-title}
  23. If the user cannot be authenticated, this API returns a 401 status code.
  24. [[security-api-authenticate-example]]
  25. ==== {api-examples-title}
  26. To authenticate a user, submit a GET request to the
  27. `/_security/_authenticate` endpoint:
  28. [source,console]
  29. --------------------------------------------------
  30. GET /_security/_authenticate
  31. --------------------------------------------------
  32. The following example output provides information about the "rdeniro" user:
  33. [source,console-result]
  34. --------------------------------------------------
  35. {
  36. "username": "rdeniro",
  37. "roles": [
  38. "admin"
  39. ],
  40. "full_name": null,
  41. "email": null,
  42. "metadata": { },
  43. "enabled": true,
  44. "authentication_realm": {
  45. "name" : "file",
  46. "type" : "file"
  47. },
  48. "lookup_realm": {
  49. "name" : "file",
  50. "type" : "file"
  51. },
  52. "authentication_type": "realm"
  53. }
  54. --------------------------------------------------
  55. // TESTRESPONSE[s/"rdeniro"/"$body.username"/]
  56. // TESTRESPONSE[s/"admin"/"_es_test_root"/]