|
@@ -1,6 +1,6 @@
|
|
|
[role="xpack"]
|
|
|
[[security-api-get-api-key]]
|
|
|
-=== Get API Key information API
|
|
|
+=== Get API key information API
|
|
|
++++
|
|
|
<titleabbrev>Get API key information</titleabbrev>
|
|
|
++++
|
|
@@ -22,38 +22,70 @@ The following parameters can be specified in the query parameters of a GET reque
|
|
|
pertain to retrieving api keys:
|
|
|
|
|
|
`id` (optional)::
|
|
|
-(string) An API key id. This parameter cannot be used with any of `name`, `realm_name` or
|
|
|
- `username` are used.
|
|
|
+(string) An API key id. This parameter cannot be used with any of `name`,
|
|
|
+`realm_name` or `username` are used.
|
|
|
|
|
|
`name` (optional)::
|
|
|
-(string) An API key name. This parameter cannot be used with any of `id`, `realm_name` or
|
|
|
- `username` are used.
|
|
|
+(string) An API key name. This parameter cannot be used with any of `id`,
|
|
|
+`realm_name` or `username` are used.
|
|
|
|
|
|
`realm_name` (optional)::
|
|
|
-(string) The name of an authentication realm. This parameter cannot be used with either `id` or `name`.
|
|
|
+(string) The name of an authentication realm. This parameter cannot be used with
|
|
|
+either `id` or `name`.
|
|
|
|
|
|
`username` (optional)::
|
|
|
-(string) The username of a user. This parameter cannot be used with either `id` or `name`.
|
|
|
+(string) The username of a user. This parameter cannot be used with either `id`
|
|
|
+or `name`.
|
|
|
|
|
|
NOTE: While all parameters are optional, at least one of them is required.
|
|
|
|
|
|
==== Examples
|
|
|
|
|
|
-The following example to retrieve the API key identified by specified `id`:
|
|
|
+If you create an API key as follows:
|
|
|
+
|
|
|
+[source, js]
|
|
|
+------------------------------------------------------------
|
|
|
+POST /_security/api_key
|
|
|
+{
|
|
|
+ "name": "my-api-key",
|
|
|
+ "role_descriptors": {}
|
|
|
+}
|
|
|
+------------------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST
|
|
|
+
|
|
|
+A successful call returns a JSON structure that provides
|
|
|
+API key information. For example:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-GET /_security/api_key?id=dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==
|
|
|
+{
|
|
|
+ "id":"VuaCfGcBCdbkQm-e5aOx",
|
|
|
+ "name":"my-api-key",
|
|
|
+ "api_key":"ui2lp2axTNmsyakw9tvNnw"
|
|
|
+}
|
|
|
--------------------------------------------------
|
|
|
-// NOTCONSOLE
|
|
|
+// TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
|
|
|
+// TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/]
|
|
|
|
|
|
-whereas the following example to retrieve the API key identified by specified `name`:
|
|
|
+You can use the following example to retrieve the API key by ID:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-GET /_security/api_key?name=hadoop_myuser_key
|
|
|
+GET /_security/api_key?id=VuaCfGcBCdbkQm-e5aOx
|
|
|
--------------------------------------------------
|
|
|
-// NOTCONSOLE
|
|
|
+// CONSOLE
|
|
|
+// TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
|
|
|
+// TEST[continued]
|
|
|
+
|
|
|
+You can use the following example to retrieve the API key by name:
|
|
|
+
|
|
|
+[source,js]
|
|
|
+--------------------------------------------------
|
|
|
+GET /_security/api_key?name=my-api-key
|
|
|
+--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[continued]
|
|
|
|
|
|
The following example retrieves all API keys for the `native1` realm:
|
|
|
|
|
@@ -61,7 +93,8 @@ The following example retrieves all API keys for the `native1` realm:
|
|
|
--------------------------------------------------
|
|
|
GET /_security/api_key?realm_name=native1
|
|
|
--------------------------------------------------
|
|
|
-// NOTCONSOLE
|
|
|
+// CONSOLE
|
|
|
+// TEST[continued]
|
|
|
|
|
|
The following example retrieves all API keys for the user `myuser` in all realms:
|
|
|
|
|
@@ -69,7 +102,8 @@ The following example retrieves all API keys for the user `myuser` in all realms
|
|
|
--------------------------------------------------
|
|
|
GET /_security/api_key?username=myuser
|
|
|
--------------------------------------------------
|
|
|
-// NOTCONSOLE
|
|
|
+// CONSOLE
|
|
|
+// TEST[continued]
|
|
|
|
|
|
Finally, the following example retrieves all API keys for the user `myuser` in
|
|
|
the `native1` realm immediately:
|
|
@@ -78,7 +112,8 @@ Finally, the following example retrieves all API keys for the user `myuser` in
|
|
|
--------------------------------------------------
|
|
|
GET /_security/api_key?username=myuser&realm_name=native1
|
|
|
--------------------------------------------------
|
|
|
-// NOTCONSOLE
|
|
|
+// CONSOLE
|
|
|
+// TEST[continued]
|
|
|
|
|
|
A successful call returns a JSON structure that contains the information of one or more API keys that were retrieved.
|
|
|
|
|
@@ -112,7 +147,8 @@ A successful call returns a JSON structure that contains the information of one
|
|
|
<2> Id for the API key
|
|
|
<3> Name of the API key
|
|
|
<4> Creation time for the API key in milliseconds
|
|
|
-<5> optional expiration time for the API key in milliseconds
|
|
|
-<6> invalidation status for the API key, `true` if the key has been invalidated else `false`
|
|
|
-<7> principal for which this API key was created
|
|
|
-<8> realm name of the principal for which this API key was created
|
|
|
+<5> Optional expiration time for the API key in milliseconds
|
|
|
+<6> Invalidation status for the API key. If the key has been invalidated, it has
|
|
|
+a value of `true`. Otherwise, it is `false`.
|
|
|
+<7> Principal for which this API key was created
|
|
|
+<8> Realm name of the principal for which this API key was created
|