2018-08-18 02:17:33 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[[security-api-get-user]]
|
|
|
|
=== Get users API
|
2018-12-20 13:23:28 -05:00
|
|
|
++++
|
|
|
|
<titleabbrev>Get users</titleabbrev>
|
|
|
|
++++
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-07-31 10:54:00 -04:00
|
|
|
Retrieves information about users in the native realm and built-in users.
|
2018-08-18 02:17:33 -04:00
|
|
|
|
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-request]]
|
|
|
|
==== {api-request-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2018-12-11 04:13:10 -05:00
|
|
|
`GET /_security/user` +
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2018-12-11 04:13:10 -05:00
|
|
|
`GET /_security/user/<username>`
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* To use this API, you must have at least the `manage_security` cluster privilege.
|
|
|
|
|
|
|
|
|
|
|
|
[[security-api-get-user-desc]]
|
|
|
|
==== {api-description-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
|
|
|
For more information about the native realm, see
|
|
|
|
{stack-ov}/realms.html[Realms] and <<configuring-native-realm>>.
|
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
|
|
|
`username`::
|
2019-08-02 13:56:05 -04:00
|
|
|
(Optional, string) An identifier for the user. You can specify multiple
|
|
|
|
usernames as a comma-separated list. If you omit this parameter, the API
|
|
|
|
retrieves information about all users.
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-response-body]]
|
|
|
|
==== {api-response-body-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
A successful call returns an array of users with the JSON representation of the
|
|
|
|
users. Note that user passwords are not included.
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-response-codes]]
|
|
|
|
==== {api-response-codes-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
If the user is not defined in the `native` realm, the request 404s.
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2019-08-02 13:56:05 -04:00
|
|
|
[[security-api-get-user-example]]
|
|
|
|
==== {api-examples-title}
|
2018-08-18 02:17:33 -04:00
|
|
|
|
2018-12-11 04:13:10 -05:00
|
|
|
To retrieve a native user, submit a GET request to the `/_security/user/<username>`
|
2018-08-18 02:17:33 -04:00
|
|
|
endpoint:
|
|
|
|
|
2019-09-05 14:12:39 -04:00
|
|
|
[source,console]
|
2018-08-18 02:17:33 -04:00
|
|
|
--------------------------------------------------
|
2018-12-11 04:13:10 -05:00
|
|
|
GET /_security/user/jacknich
|
2018-08-18 02:17:33 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[setup:jacknich_user]
|
|
|
|
|
2019-09-05 14:12:39 -04:00
|
|
|
[source,console-result]
|
2018-08-18 02:17:33 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"jacknich": {
|
|
|
|
"username": "jacknich",
|
|
|
|
"roles": [
|
|
|
|
"admin", "other_role1"
|
|
|
|
],
|
|
|
|
"full_name": "Jack Nicholson",
|
|
|
|
"email": "jacknich@example.com",
|
|
|
|
"metadata": { "intelligence" : 7 },
|
|
|
|
"enabled": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Omit the username to retrieve all users:
|
|
|
|
|
2019-09-05 14:12:39 -04:00
|
|
|
[source,console]
|
2018-08-18 02:17:33 -04:00
|
|
|
--------------------------------------------------
|
2018-12-11 04:13:10 -05:00
|
|
|
GET /_security/user
|
2018-08-18 02:17:33 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|