get-app-privileges.asciidoc 2.8 KB

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