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

[DOCS] Corrected API path for invalidate token and SSL certificate examples #39530

Merged
merged 17 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions x-pack/docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ buildRestTests.docs = fileTree(projectDir) {
exclude 'build'
// These file simply doesn't pass yet. We should figure out how to fix them.
exclude 'en/watcher/reference/actions.asciidoc'
exclude 'en/rest-api/security/ssl.asciidoc'
}

Map<String, String> setups = buildRestTests.setups
Expand Down
119 changes: 92 additions & 27 deletions x-pack/docs/en/rest-api/security/invalidate-tokens.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ can no longer be used. That time period is defined by the
The refresh tokens returned by the <<security-api-get-token,get token API>> are
only valid for 24 hours. They can also be used exactly once.

If you want to invalidate one or more access or refresh tokens immediately, use this invalidate token API.
If you want to invalidate one or more access or refresh tokens immediately, use
this invalidate token API.


==== Request Body
Expand All @@ -31,25 +32,52 @@ The following parameters can be specified in the body of a DELETE request and
pertain to invalidating tokens:

`token` (optional)::
(string) An access token. This parameter cannot be used any of `refresh_token`, `realm_name` or
`username` are used.
(string) An access token. This parameter cannot be used any of `refresh_token`,
`realm_name` or `username` are used.

`refresh_token` (optional)::
(string) A refresh token. This parameter cannot be used any of `refresh_token`, `realm_name` or
`username` are used.
(string) A refresh token. This parameter cannot be used any of `refresh_token`,
`realm_name` or `username` are used.

`realm_name` (optional)::
(string) The name of an authentication realm. This parameter cannot be used with either `refresh_token` or `token`.
(string) The name of an authentication realm. This parameter cannot be used with
either `refresh_token` or `token`.

`username` (optional)::
(string) The username of a user. This parameter cannot be used with either `refresh_token` or `token`
(string) The username of a user. This parameter cannot be used with either
`refresh_token` or `token`

NOTE: While all parameters are optional, at least one of them is required. More specifically, either one of `token`
or `refresh_token` parameters is required. If none of these two are specified, then `realm_name` and/or `username`
need to be specified.
NOTE: While all parameters are optional, at least one of them is required. More
specifically, either one of `token` or `refresh_token` parameters is required.
If none of these two are specified, then `realm_name` and/or `username` need to
be specified.

==== Examples

For example, if you create the following token:
lcawl marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
--------------------------------------------------
POST /_security/oauth2/token
{
"grant_type" : "client_credentials"
}
--------------------------------------------------
// CONSOLE

The API returns the following information about the access token:
lcawl marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
--------------------------------------------------
{
"access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
"type" : "Bearer",
"expires_in" : 1200
}
--------------------------------------------------
// TESTRESPONSE[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

This access token can now be immediately invalidated, as shown in the following example:

The following example invalidates the specified token immediately:

[source,js]
Expand All @@ -59,57 +87,94 @@ DELETE /_security/oauth2/token
"token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ=="
}
--------------------------------------------------
// NOTCONSOLE
// CONSOLE
// TEST[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]
// TEST[continued]

If you used the `password` grant type to obtain a token for a user, the response
contains a refresh token. For example:
lcawl marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
--------------------------------------------------
POST /_security/oauth2/token
{
"grant_type" : "password",
"username" : "test_admin",
"password" : "x-pack-test-password"
}
--------------------------------------------------
// CONSOLE
// TEST

whereas the following example invalidates the specified refresh token immediately:
The API returns the following information:
lcawl marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
--------------------------------------------------
{
"access_token" : "dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==",
"type" : "Bearer",
"expires_in" : 1200,
"refresh_token": "vLBPvmAB6KvwvJZr27cS"
}
--------------------------------------------------
// TESTRESPONSE[s/dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==/$body.access_token/]
// TESTRESPONSE[s/vLBPvmAB6KvwvJZr27cS/$body.refresh_token/]

You can invalidate the specified refresh token as follows:
lcawl marked this conversation as resolved.
Show resolved Hide resolved

[source,js]
--------------------------------------------------
DELETE /_security/oauth2/token
{
"refresh_token" : "movUJjPGRRC0PQ7+NW0eag"
"refresh_token" : "vLBPvmAB6KvwvJZr27cS"
}
--------------------------------------------------
// NOTCONSOLE
// CONSOLE
// TEST[s/vLBPvmAB6KvwvJZr27cS/$body.refresh_token/]
// TEST[continued]


The following example invalidates all access tokens and refresh tokens for the `saml1` realm immediately:
The following example invalidates all access tokens and refresh tokens for the
`saml1` realm immediately:

[source,js]
--------------------------------------------------
DELETE /_xpack/security/oauth2/token
DELETE /_security/oauth2/token
{
"realm_name" : "saml1"
}
--------------------------------------------------
// NOTCONSOLE
// CONSOLE
// TEST

The following example invalidates all access tokens and refresh tokens for the user `myuser` in all realms immediately:
The following example invalidates all access tokens and refresh tokens for the
user `myuser` in all realms immediately:

[source,js]
--------------------------------------------------
DELETE /_xpack/security/oauth2/token
DELETE /_security/oauth2/token
{
"username" : "myuser"
}
--------------------------------------------------
// NOTCONSOLE
// CONSOLE

Finally, the following example invalidates all access tokens and refresh tokens for the user `myuser` in
the `saml1` realm immediately:
Finally, the following example invalidates all access tokens and refresh tokens
for the user `myuser` in the `saml1` realm immediately:

[source,js]
--------------------------------------------------
DELETE /_xpack/security/oauth2/token
DELETE /_security/oauth2/token
{
"username" : "myuser",
"realm_name" : "saml1"
}
--------------------------------------------------
// NOTCONSOLE
// CONSOLE

A successful call returns a JSON structure that contains the number of tokens that were invalidated, the number
of tokens that had already been invalidated, and potentially a list of errors encountered while invalidating
specific tokens.
A successful call returns a JSON structure that contains the number of tokens
that were invalidated, the number of tokens that had already been invalidated,
and potentially a list of errors encountered while invalidating specific tokens.

[source,js]
--------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions x-pack/docs/en/rest-api/security/ssl.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ node of {es}:

[source,js]
--------------------------------------------------
GET /_xpack/certificates
GET /_ssl/certificates
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST

The API returns the following results:

[source,js]
----
[
Expand Down Expand Up @@ -116,4 +117,4 @@ The API returns the following results:
}
]
----
// NOTCONSOLE
// NOTCONSOLE