authenticate.asciidoc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 what roles are assigned
  10. to the user as well as any assigned metadata.
  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. }
  33. --------------------------------------------------
  34. // TESTRESPONSE[s/"rdeniro"/"$body.username"/]
  35. // TESTRESPONSE[s/"admin"/"superuser"/]