has-privileges-user-profile.asciidoc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. [role="xpack"]
  2. [[security-api-has-privileges-user-profile]]
  3. === Has privileges user profile API
  4. ++++
  5. <titleabbrev>Has privileges user profile</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. NOTE: The user profile feature is designed only for use by {kib} and
  13. Elastic’s {observability}, {ents}, and {elastic-sec} solutions. Individual
  14. users and external applications should not call this API directly. Elastic reserves
  15. the right to change or remove this feature in future releases without prior notice.
  16. Determines whether the users associated with the specified <<user-profile, user profile>> IDs
  17. have all the requested privileges.
  18. [[security-api-has-privileges-user-profile-request]]
  19. ==== {api-request-title}
  20. `GET /_security/profile/_has_privileges`
  21. `POST /_security/profile/_has_privileges`
  22. [[security-api-has-privileges-user-profile-prereqs]]
  23. ==== {api-prereq-title}
  24. To use this API, you must have _at least_ the `read_security`
  25. <<privileges-list-cluster,cluster privilege>> (or a greater privilege
  26. such as `manage_user_profile` or `manage_security`).
  27. [[security-api-has-privileges-user-profile-desc]]
  28. ==== {api-description-title}
  29. This API uses the profile IDs, as returned by <<security-api-activate-user-profile>>,
  30. to identify the users for which to check the privileges of.
  31. It is similar to the <<security-api-has-privileges>> API, but unlike it, this API
  32. checks the privileges of other users, not of the user that's calling it.
  33. See <<security-privileges>> for the list of privileges that can be specified in this API.
  34. A successful call returns the subset list of profile IDs that have **all** the requested privileges.
  35. [[security-api-has-privileges-user-profile-request-body]]
  36. ==== {api-request-body-title}
  37. `uids`:: (list) A list of <<security-api-activate-user-profile-response-body, profile IDs>>. The privileges are checked for associated users of the profiles.
  38. `privileges`:: The object containing all the privileges to be checked.
  39. `cluster`::: (list) A list of the cluster privileges that you want to check.
  40. `index`:::
  41. `names`:::: (list) A list of indices.
  42. `allow_restricted_indices`:::: (Boolean) This needs to be set to `true` (default
  43. is `false`) if using wildcards or regexps for patterns that cover restricted
  44. indices. Implicitly, restricted indices do not match index patterns because
  45. restricted indices usually have limited privileges and including them in
  46. pattern tests would render most such tests `false`. If restricted indices are
  47. explicitly included in the `names` list, privileges will be checked against
  48. them regardless of the value of `allow_restricted_indices`.
  49. `privileges`:::: (list) A list of the privileges that you want to check for the
  50. specified indices.
  51. `application`:::
  52. `application`:::: (string) The name of the application.
  53. `privileges`:::: (list) A list of the privileges that you want to check for the
  54. specified resources. May be either application privilege names, or the names of
  55. actions that are granted by those privileges.
  56. `resources`:::: (list) A list of resource names against which the privileges
  57. should be checked.
  58. Note that the `privileges` section above is identical to the
  59. <<security-api-has-privileges-request-body, request body of the other Has Privileges API>>.
  60. [[security-api-has-privileges-user-profile-response-body]]
  61. ==== {api-response-body-title}
  62. A successful has privileges user profile API call returns a JSON structure that contains
  63. two fields:
  64. `has_privilege_uids`:: (list) The subset of the requested profile IDs of the users that have
  65. **all** the requested privileges.
  66. `errors`:: (object) Errors encountered while fulfilling the request. This field is absent if there is no error.
  67. It does **not** include the profile IDs of the users that do not have all the requested privileges.
  68. +
  69. .Properties of objects in `errors`
  70. [%collapsible%open]
  71. ====
  72. `count`:: (number) Total number of errors
  73. `details`:: (object) The detailed error report with keys being profile IDs and values being the exact errors.
  74. ====
  75. [[security-api-has-privileges-user-profile-example]]
  76. ==== {api-examples-title}
  77. The following example checks whether the two users associated with the specified profiles have all the
  78. requested set of cluster, index, and application privileges:
  79. [source,console]
  80. --------------------------------------------------
  81. POST /_security/profile/_has_privileges
  82. {
  83. "uids": [
  84. "u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0",
  85. "u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1",
  86. "u_does-not-exist_0"
  87. ],
  88. "privileges": {
  89. "cluster": [ "monitor", "create_snapshot", "manage_ml" ],
  90. "index" : [
  91. {
  92. "names": [ "suppliers", "products" ],
  93. "privileges": [ "create_doc"]
  94. },
  95. {
  96. "names": [ "inventory" ],
  97. "privileges" : [ "read", "write" ]
  98. }
  99. ],
  100. "application": [
  101. {
  102. "application": "inventory_manager",
  103. "privileges" : [ "read", "data:write/inventory" ],
  104. "resources" : [ "product/1852563" ]
  105. }
  106. ]
  107. }
  108. }
  109. --------------------------------------------------
  110. // TEST[skip:TODO setup and tests will be possible once the profile uid is predictable]
  111. The following example output indicates that only one of the three users has all the privileges
  112. and one of them is not found:
  113. [source,js]
  114. --------------------------------------------------
  115. {
  116. "has_privilege_uids": ["u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1"],
  117. "errors": {
  118. "count": 1,
  119. "details": {
  120. "u_does-not-exist_0": {
  121. "type": "resource_not_found_exception",
  122. "reason": "profile document not found"
  123. }
  124. }
  125. }
  126. }
  127. --------------------------------------------------
  128. // NOTCONSOLE