1
0

get-users.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. [role="xpack"]
  2. [[security-api-get-user]]
  3. === Get users API
  4. ++++
  5. <titleabbrev>Get users</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 information about users in the native realm and built-in users.
  13. [[security-api-get-user-request]]
  14. ==== {api-request-title}
  15. `GET /_security/user` +
  16. `GET /_security/user/<username>`
  17. [[security-api-get-user-prereqs]]
  18. ==== {api-prereq-title}
  19. * To use this API, you must have at least the `read_security` cluster privilege.
  20. [[security-api-get-user-desc]]
  21. ==== {api-description-title}
  22. For more information about the native realm, see
  23. <<realms>> and <<native-realm>>.
  24. [[security-api-get-user-path-params]]
  25. ==== {api-path-parms-title}
  26. `username`::
  27. (Optional, string) An identifier for the user. You can specify multiple
  28. usernames as a comma-separated list. If you omit this parameter, the API
  29. retrieves information about all users.
  30. [[security-api-get-user-query-params]]
  31. ==== {api-query-parms-title}
  32. `with_profile_uid`::
  33. (Optional, boolean) Determines whether to retrieve the <<user-profile,user profile>> `uid`,
  34. if exists, for the users. Defaults to `false`.
  35. [[security-api-get-user-response-body]]
  36. ==== {api-response-body-title}
  37. A successful call returns an array of users with the JSON representation of the
  38. users. Note that user passwords are not included.
  39. [[security-api-get-user-response-codes]]
  40. ==== {api-response-codes-title}
  41. If the user is not defined in the `native` realm, the request 404s.
  42. [[security-api-get-user-example]]
  43. ==== {api-examples-title}
  44. To retrieve a native user, submit a GET request to the `/_security/user/<username>`
  45. endpoint:
  46. [source,console]
  47. --------------------------------------------------
  48. GET /_security/user/jacknich
  49. --------------------------------------------------
  50. // TEST[setup:jacknich_user]
  51. [source,console-result]
  52. --------------------------------------------------
  53. {
  54. "jacknich": {
  55. "username": "jacknich",
  56. "roles": [
  57. "admin", "other_role1"
  58. ],
  59. "full_name": "Jack Nicholson",
  60. "email": "jacknich@example.com",
  61. "metadata": { "intelligence" : 7 },
  62. "enabled": true
  63. }
  64. }
  65. --------------------------------------------------
  66. To retrieve the user `profile_uid` as part of the response:
  67. [source,console]
  68. --------------------------------------------------
  69. GET /_security/user/jacknich?with_profile_uid=true
  70. --------------------------------------------------
  71. // TEST[continued]
  72. [source,console-result]
  73. --------------------------------------------------
  74. {
  75. "jacknich": {
  76. "username": "jacknich",
  77. "roles": [
  78. "admin", "other_role1"
  79. ],
  80. "full_name": "Jack Nicholson",
  81. "email": "jacknich@example.com",
  82. "metadata": { "intelligence" : 7 },
  83. "enabled": true,
  84. "profile_uid": "u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0"
  85. }
  86. }
  87. --------------------------------------------------
  88. Omit the username to retrieve all users:
  89. [source,console]
  90. --------------------------------------------------
  91. GET /_security/user
  92. --------------------------------------------------
  93. // TEST[continued]