get-app-privileges.asciidoc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. [role="xpack"]
  2. [[security-api-get-privileges]]
  3. === Get application privileges API
  4. ++++
  5. <titleabbrev>Get application privileges</titleabbrev>
  6. ++++
  7. Retrieves <<application-privileges,application privileges>>.
  8. [[security-api-get-privileges-request]]
  9. ==== {api-request-title}
  10. `GET /_security/privilege` +
  11. `GET /_security/privilege/<application>` +
  12. `GET /_security/privilege/<application>/<privilege>`
  13. [[security-api-get-privileges-prereqs]]
  14. ==== {api-prereq-title}
  15. To use this API, you must have either:
  16. - the `read_security` cluster privilege (or a greater privilege such as `manage_security` or `all`); _or_
  17. - the _"Manage Application Privileges"_ global privilege for the application being referenced
  18. in the request
  19. [[security-api-get-privileges-desc]]
  20. ==== {api-description-title}
  21. To check a user's application privileges, use the
  22. <<security-api-has-privileges,has privileges API>>.
  23. [[security-api-get-privileges-path-params]]
  24. ==== {api-path-parms-title}
  25. `application`::
  26. (Optional, string) The name of the application. Application privileges are
  27. always associated with exactly one application. If you do not specify this
  28. parameter, the API returns information about all privileges for all
  29. applications.
  30. `privilege`::
  31. (Optional, string) The name of the privilege. If you do not specify this
  32. parameter, the API returns information about all privileges for the requested
  33. application.
  34. [[security-api-get-privileges-example]]
  35. ==== {api-examples-title}
  36. The following example retrieves information about the `read` privilege for the
  37. `app01` application:
  38. [source,console]
  39. --------------------------------------------------
  40. GET /_security/privilege/myapp/read
  41. --------------------------------------------------
  42. // TEST[setup:app0102_privileges]
  43. A successful call returns an object keyed by application name and privilege
  44. name. If the privilege is not defined, the request responds with a 404 status.
  45. [source,console-result]
  46. --------------------------------------------------
  47. {
  48. "myapp": {
  49. "read": {
  50. "application": "myapp",
  51. "name": "read",
  52. "actions": [
  53. "data:read/*",
  54. "action:login"
  55. ],
  56. "metadata": {
  57. "description": "Read access to myapp"
  58. }
  59. }
  60. }
  61. }
  62. --------------------------------------------------
  63. To retrieve all privileges for an application, omit the privilege name:
  64. [source,console]
  65. --------------------------------------------------
  66. GET /_security/privilege/myapp/
  67. --------------------------------------------------
  68. To retrieve every privilege, omit both the application and privilege names:
  69. [source,console]
  70. --------------------------------------------------
  71. GET /_security/privilege/
  72. --------------------------------------------------