Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document API key API changes for owner flag #45698

Merged
merged 5 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions x-pack/docs/en/rest-api/security/get-api-keys.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ pertain to retrieving api keys:

`realm_name`::
(Optional, string) The name of an authentication realm. This parameter cannot be
used with either `id` or `name`.
used with either `id` or `name` or when `owner` flag is set to `true`.

`username`::
(Optional, string) The username of a user. This parameter cannot be used with
either `id` or `name`.
either `id` or `name` or when `owner` flag is set to `true`.

NOTE: While all parameters are optional, at least one of them is required.
`owner`::
(Optional, boolean) A boolean flag that can be used to query API keys owned
by the currently authenticated user. Defaults to false. If this parameter is set to
`true` then `realm_name` or `username` parameters cannot be specified as
they default to the authenticated users name and realm name.
bizybot marked this conversation as resolved.
Show resolved Hide resolved

NOTE: While all parameters are optional, at least one of them is required when `owner`
bizybot marked this conversation as resolved.
Show resolved Hide resolved
flag is set to `false`.

[[security-api-get-api-key-example]]
==== {api-examples-title}
Expand Down Expand Up @@ -114,6 +121,37 @@ GET /_security/api_key?username=myuser
// CONSOLE
// TEST[continued]

The following example retrieves all API keys owned by the currently authenticated user:

[source,js]
--------------------------------------------------
GET /_security/api_key?owner=true
--------------------------------------------------
// CONSOLE
// TEST[continued]

Following creates an API key

[source, js]
------------------------------------------------------------
POST /_security/api_key
{
"name": "my-api-key-1"
}
------------------------------------------------------------
// CONSOLE

The following example retrieves the API key identified by the specified `id` if
it is owned by the currently authenticated user:

[source,js]
--------------------------------------------------
GET /_security/api_key?id=VuaCfGcBCdbkQm-e5aOx&owner=true
--------------------------------------------------
// CONSOLE
// TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
// TEST[continued]

Finally, the following example retrieves all API keys for the user `myuser` in
the `native1` realm immediately:

Expand Down
39 changes: 36 additions & 3 deletions x-pack/docs/en/rest-api/security/invalidate-api-keys.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ pertain to invalidating api keys:

`realm_name`::
(Optional, string) The name of an authentication realm. This parameter cannot be
used with either `id` or `name`.
used with either `id` or `name` or when `owner` flag is set to `true`.

`username`::
(Optional, string) The username of a user. This parameter cannot be used with
either `id` or `name`.
either `id` or `name` or when `owner` flag is set to `true`.

NOTE: While all parameters are optional, at least one of them is required.
`owner`::
(Optional, boolean) A boolean flag that can be used to query API keys owned
by the currently authenticated user. Defaults to false. If this parameter is set to
`true` then `realm_name` or `username` parameters cannot be specified as
they default to the authenticated users name and realm name.

NOTE: While all parameters are optional, at least one of them is required when `owner`
flag is set to `false`.
bizybot marked this conversation as resolved.
Show resolved Hide resolved

[[security-api-invalidate-api-key-response-body]]
==== {api-response-body-title}
Expand Down Expand Up @@ -138,6 +145,32 @@ DELETE /_security/api_key
// CONSOLE
// TEST

The following example invalidates the API key identified by the specified `id` if
it is owned by the currently authenticated user immediately:

[source,js]
--------------------------------------------------
DELETE /_security/api_key
{
"id" : "VuaCfGcBCdbkQm-e5aOx",
"owner" : "true"
}
--------------------------------------------------
// CONSOLE

The following example invalidates all API keys owned by the currently authenticated
user immediately:

[source,js]
--------------------------------------------------
DELETE /_security/api_key
{
"owner" : "true"
}
--------------------------------------------------
// CONSOLE
// TEST

Finally, the following example invalidates all API keys for the user `myuser` in
the `native1` realm immediately:

Expand Down