has-privileges.asciidoc 3.3 KB

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