authenticate.asciidoc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [role="xpack"]
  2. [[security-api-authenticate]]
  3. === Authenticate API
  4. The Authenticate API enables you to submit a request with a basic auth header to
  5. authenticate a user and retrieve information about the authenticated user.
  6. ==== Request
  7. `GET _xpack/security/_authenticate`
  8. ==== Description
  9. A successful call returns a JSON structure that shows user information such as their username, the roles that are
  10. assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
  11. If the user cannot be authenticated, this API returns a 401 status code.
  12. ==== Examples
  13. To authenticate a user, submit a GET request to the
  14. `_xpack/security/_authenticate` endpoint:
  15. [source,js]
  16. --------------------------------------------------
  17. GET _xpack/security/_authenticate
  18. --------------------------------------------------
  19. // CONSOLE
  20. The following example output provides information about the "rdeniro" user:
  21. [source,js]
  22. --------------------------------------------------
  23. {
  24. "username": "rdeniro",
  25. "roles": [
  26. "admin"
  27. ],
  28. "full_name": null,
  29. "email": null,
  30. "metadata": { },
  31. "enabled": true,
  32. "authentication_realm": {
  33. "name" : "default_file",
  34. "type" : "file"
  35. },
  36. "lookup_realm": {
  37. "name" : "default_file",
  38. "type" : "file"
  39. }
  40. }
  41. --------------------------------------------------
  42. // TESTRESPONSE[s/"rdeniro"/"$body.username"/]
  43. // TESTRESPONSE[s/"admin"/"superuser"/]