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

Add docs and rest api spec for saml complete logout API #72867

Merged
merged 5 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"security.saml_complete_logout":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html",
"description":"Verifies the logout response sent from the SAML IdP"
},
"stability":"stable",
"visibility":"public",
"headers":{
"accept": [ "application/json"],
"content_type": ["application/json"]
},
"url":{
"paths":[
{
"path":"/_security/saml/complete_logout",
"methods":[
"POST"
]
}
]
},
"body":{
"description":"The logout response to verify",
"required":true
}
}
}
2 changes: 2 additions & 0 deletions x-pack/docs/en/rest-api/security.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ realm when using a custom web application other than Kibana
* <<security-api-saml-authenticate, Submit an authentication response>>
* <<security-api-saml-logout, Logout an authenticated user>>
* <<security-api-saml-invalidate, Submit a logout request from the IdP>>
* <<security-api-saml-complete-logout, Verify a logout response from the IdP>>
* <<security-api-saml-sp-metadata,Generate SAML metadata>>

[discrete]
Expand Down Expand Up @@ -171,5 +172,6 @@ include::security/saml-prepare-authentication-api.asciidoc[]
include::security/saml-authenticate-api.asciidoc[]
include::security/saml-logout-api.asciidoc[]
include::security/saml-invalidate-api.asciidoc[]
include::security/saml-complete-logout-api.asciidoc[]
include::security/saml-sp-metadata.asciidoc[]
include::security/ssl.asciidoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ These APIs are used internally by {kib} in order to provide SAML based
authentication, but can also be used by other, custom web applications or other
clients. See also
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
<<security-api-saml-invalidate,SAML invalidate API>> and
<<security-api-saml-logout,SAML logout API>>.
<<security-api-saml-invalidate,SAML invalidate API>>,
<<security-api-saml-logout,SAML logout API>>, and
<<security-api-saml-complete-logout, SAML complete logout API>>.


[[security-api-saml-authenticate-request-body]]
Expand Down
89 changes: 89 additions & 0 deletions x-pack/docs/en/rest-api/security/saml-complete-logout-api.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[role="xpack"]
[[security-api-saml-complete-logout]]
=== SAML complete logout API
++++
<titleabbrev>SAML complete logout</titleabbrev>
++++

Verifies the logout response sent from the SAML IdP.

NOTE: This API is intended for use by custom web applications other than {kib}.
If you are using {kib}, see the <<saml-guide>>.

[[security-api-saml-complete-logout-request]]
==== {api-request-title}

`POST /_security/saml/complete_logout`

[[security-api-saml-complete-logout-desc]]
==== {api-description-title}

The SAML IdP may send a logout response back to the SP after handling
the <<security-api-saml-logout,SP-initiated SAML Single Logout>>.
This API verifies the response by ensuring the content is relevant
and validating its signature. An empty response is returned if
the verification process is successful.
The response can be sent by the IdP with either the HTTP-Redirect or
the HTTP-Post binding. The caller of this API must prepare the request
accordingly so that this API can handle either of them.

{es} exposes all the necessary SAML related functionality via the SAML APIs.
These APIs are used internally by {kib} in order to provide SAML based
authentication, but can also be used by other custom web applications or other
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
<<security-api-saml-invalidate,SAML invalidate API>>, and
<<security-api-saml-logout,SAML logout API>>.

[[security-api-saml-complete-logout-request-body]]
==== {api-request-body-title}

`realm`::
(Required, string) The name of the SAML realm in {es} for which the configuration is
used to verify the logout response.

`ids`::
(Required, array) A json array with all the valid SAML Request Ids that the caller of
the API has for the current user.

`queryString`::
Copy link
Member Author

Choose a reason for hiding this comment

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

I think our APIs generally prefer snake case. So this should have been query_string instead of queryString. This is unfortunately another oversight of the original PR #56316. I can deprecate it and add a new query_string field in another follow-up PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, maybe raise an issue for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I raised #73543

(Optional, string) If the SAML IdP sends the logout response with the HTTP-Redirect
binding, this field must be set to the query string of the redirect URI.

`content`::
(Optional, string) If the SAML IdP sends the logout response with the HTTP-Post
binding, this field must be set to the value of the `SAMLResponse` form parameter
from the logout response.

[[security-api-saml-complete-logout-example]]
==== {api-examples-title}

The following example verifies the logout response sent by the SAML IdP
using the HTTP-Redirect binding:

[source,console]
--------------------------------------------------
POST /_security/saml/complete_logout
{
"realm": "saml1",
"ids": [ "_1c368075e0b3..." ],
"queryString": "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK..."
}
--------------------------------------------------
// TEST[skip:can't test this without a valid SAML Logout Response]

If the logout response is sent with the HTTP-Post binding, it can be verified
as the follows:

[source,console]
--------------------------------------------------
POST /_security/saml/complete_logout
{
"realm": "saml1",
"ids": [ "_1c368075e0b3..." ],
"content": "PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46..."
}
--------------------------------------------------
// TEST[skip:can't test this without a valid SAML Logout Response]

The API returns an empty response on success.
11 changes: 6 additions & 5 deletions x-pack/docs/en/rest-api/security/saml-invalidate-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ These APIs are used internally by {kib} in order to provide SAML based
authentication, but can also be used by other custom web applications or other
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
and <<security-api-saml-logout,SAML logout API>>.
<<security-api-saml-logout,SAML logout API>>, and
<<security-api-saml-complete-logout, SAML complete logout API>>.

[[security-api-saml-invalidate-request-body]]
==== {api-request-body-title}
Expand All @@ -39,11 +40,11 @@ and <<security-api-saml-logout,SAML logout API>>.
(Optional, string) The Assertion Consumer Service URL that matches the one of the SAML
realm in {es} that should be used. You must specify either this parameter or the `realm` parameter.

`queryString`::
`queryString`::
(Required, string) The query part of the URL that the user was redirected to by the SAML
IdP to initiate the Single Logout. This query should include a single
parameter named `SAMLRequest` that contains a SAML logout request that is
deflated and Base64 encoded. If the SAML IdP has signed the logout request,
deflated and Base64 encoded. If the SAML IdP has signed the logout request,
the URL should include two extra parameters named `SigAlg` and `Signature`
that contain the algorithm used for the signature and the signature value itself.
In order for {es} to be able to verify the IdP's signature, the value of the queryString field must be an exact match to the string provided by the browser.
Expand All @@ -54,12 +55,12 @@ The client application must not attempt to parse or process the string in any wa
either this parameter or the `acs` parameter.

[[security-api-saml-invalidate-response-body]]
==== {api-response-body-title}
==== {api-response-body-title}

`invalidated`::
(integer) The number of tokens that were invalidated as part of this logout.

`realm`::
`realm`::
(string) The realm name of the SAML realm in {es} that authenticated the user.

`redirect`::
Expand Down
5 changes: 3 additions & 2 deletions x-pack/docs/en/rest-api/security/saml-logout-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ These APIs are used internally by {kib} in order to provide SAML based
authentication, but can also be used by other custom web applications or other
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
and <<security-api-saml-invalidate,SAML invalidate API>>.
<<security-api-saml-invalidate,SAML invalidate API>>, and
<<security-api-saml-complete-logout, SAML complete logout API>>.

[[security-api-saml-logout-request-body]]
==== {api-request-body-title}
Expand All @@ -47,7 +48,7 @@ and <<security-api-saml-invalidate,SAML invalidate API>>.
most recent refresh token that was received after refreshing the original access token.

[[security-api-saml-logout-response-body]]
==== {api-response-body-title}
==== {api-response-body-title}

`redirect`::
(string) A URL that contains a SAML logout request as a parameter. The user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ the authentication process (see <<security-api-saml-authenticate,SAML authentica
These APIs are used internally by {kib} in order to provide SAML based
authentication, but can also be used by other custom web applications or other
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
<<security-api-saml-invalidate,SAML invalidate API>>, and
<<security-api-saml-logout,SAML logout API>>.
<<security-api-saml-invalidate,SAML invalidate API>>,
<<security-api-saml-logout,SAML logout API>>, and
<<security-api-saml-complete-logout, SAML complete logout API>>.

[[security-api-saml-prepare-authentication-request-body]]
==== {api-request-body-title}
Expand All @@ -51,7 +52,7 @@ clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
parameter.

[[security-api-saml-prepare-authentication-response-body]]
==== {api-response-body-title}
==== {api-response-body-title}

`id`::
(string) A unique identifier for the SAML Request to be stored by the caller
Expand Down
3 changes: 3 additions & 0 deletions x-pack/docs/en/security/authentication/saml-guide.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,3 +1037,6 @@ POST /_security/saml/invalidate
The custom web application will then need to also handle the response, which will include a `redirect`
parameter with a URL in the IdP that contains the SAML Logout response. The application should redirect the user
there to complete the logout.

For SP-initiated Single Logout, the IdP may send back a logout response which can be verified by {es}
using the <<security-api-saml-complete-logout,SAML complete logout API>>.