has-privileges.asciidoc 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --
  2. :api: has-privileges
  3. :request: HasPrivilegesRequest
  4. :response: HasPrivilegesResponse
  5. --
  6. [role="xpack"]
  7. [id="{upid}-{api}"]
  8. === Has Privileges API
  9. [id="{upid}-{api}-request"]
  10. ==== Has Privileges Request
  11. The +{request}+ supports checking for any or all of the following privilege types:
  12. * Cluster Privileges
  13. * Index Privileges
  14. * Application Privileges
  15. Privileges types that you do not wish to check my be passed in as +null+, but as least
  16. one privilege must be specified.
  17. ["source","java",subs="attributes,callouts,macros"]
  18. --------------------------------------------------
  19. include-tagged::{doc-tests-file}[{api}-request]
  20. --------------------------------------------------
  21. include::../execution.asciidoc[]
  22. [id="{upid}-{api}-response"]
  23. ==== Has Privileges Response
  24. The returned +{response}+ contains the following properties
  25. `username`::
  26. The username (userid) of the current user (for whom the "has privileges"
  27. check was executed)
  28. `hasAllRequested`::
  29. `true` if the user has all of the privileges that were specified in the
  30. +{request}+. Otherwise `false`.
  31. `clusterPrivileges`::
  32. A `Map<String,Boolean>` where each key is the name of one of the cluster
  33. privileges specified in the request, and the value is `true` if the user
  34. has that privilege, and `false` otherwise.
  35. +
  36. The method `hasClusterPrivilege` can be used to retrieve this information
  37. in a more fluent manner. This method throws an `IllegalArgumentException`
  38. if the privilege was not included in the response (which will be the case
  39. if the privilege was not part of the request).
  40. `indexPrivileges`::
  41. A `Map<String, Map<String, Boolean>>` where each key is the name of an
  42. index (as specified in the +{request}+) and the value is a `Map` from
  43. privilege name to a `Boolean`. The `Boolean` value is `true` if the user
  44. has that privilege on that index, and `false` otherwise.
  45. +
  46. The method `hasIndexPrivilege` can be used to retrieve this information
  47. in a more fluent manner. This method throws an `IllegalArgumentException`
  48. if the privilege was not included in the response (which will be the case
  49. if the privilege was not part of the request).
  50. `applicationPrivileges`::
  51. A `Map<String, Map<String, Map<String, Boolean>>>>` where each key is the
  52. name of an application (as specified in the +{request}+).
  53. For each application, the value is a `Map` keyed by resource name, with
  54. each value being another `Map` from privilege name to a `Boolean`.
  55. The `Boolean` value is `true` if the user has that privilege on that
  56. resource for that application, and `false` otherwise.
  57. +
  58. The method `hasApplicationPrivilege` can be used to retrieve this
  59. information in a more fluent manner. This method throws an
  60. `IllegalArgumentException` if the privilege was not included in the
  61. response (which will be the case if the privilege was not part of the
  62. request).
  63. ["source","java",subs="attributes,callouts,macros"]
  64. --------------------------------------------------
  65. include-tagged::{doc-tests-file}[{api}-response]
  66. --------------------------------------------------
  67. <1> `hasMonitor` will be `true` if the user has the `"monitor"`
  68. cluster privilege.
  69. <2> `hasWrite` will be `true` if the user has the `"write"`
  70. privilege on the `"logstash-2018-10-05"` index.
  71. <3> `hasRead` will be `true` if the user has the `"read"`
  72. privilege on all possible indices that would match
  73. the `"logstash-2018-*"` pattern.