Skip to content

Commit da3d72c

Browse files
authored
Add docs and rest api spec for saml complete logout API (#72867)
This PR adds the documentation and Rest API spec file for the SAML complete logout API. It is a (overdued) follow up for #56316
1 parent 8f298f7 commit da3d72c

File tree

8 files changed

+138
-12
lines changed

8 files changed

+138
-12
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"security.saml_complete_logout":{
3+
"documentation":{
4+
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-saml-complete-logout.html",
5+
"description":"Verifies the logout response sent from the SAML IdP"
6+
},
7+
"stability":"stable",
8+
"visibility":"public",
9+
"headers":{
10+
"accept": [ "application/json"],
11+
"content_type": ["application/json"]
12+
},
13+
"url":{
14+
"paths":[
15+
{
16+
"path":"/_security/saml/complete_logout",
17+
"methods":[
18+
"POST"
19+
]
20+
}
21+
]
22+
},
23+
"body":{
24+
"description":"The logout response to verify",
25+
"required":true
26+
}
27+
}
28+
}

x-pack/docs/en/rest-api/security.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ realm when using a custom web application other than Kibana
116116
* <<security-api-saml-authenticate, Submit an authentication response>>
117117
* <<security-api-saml-logout, Logout an authenticated user>>
118118
* <<security-api-saml-invalidate, Submit a logout request from the IdP>>
119+
* <<security-api-saml-complete-logout, Verify a logout response from the IdP>>
119120
* <<security-api-saml-sp-metadata,Generate SAML metadata>>
120121

121122
[discrete]
@@ -171,5 +172,6 @@ include::security/saml-prepare-authentication-api.asciidoc[]
171172
include::security/saml-authenticate-api.asciidoc[]
172173
include::security/saml-logout-api.asciidoc[]
173174
include::security/saml-invalidate-api.asciidoc[]
175+
include::security/saml-complete-logout-api.asciidoc[]
174176
include::security/saml-sp-metadata.asciidoc[]
175177
include::security/ssl.asciidoc[]

x-pack/docs/en/rest-api/security/saml-authenticate-api.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ These APIs are used internally by {kib} in order to provide SAML based
3838
authentication, but can also be used by other, custom web applications or other
3939
clients. See also
4040
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
41-
<<security-api-saml-invalidate,SAML invalidate API>> and
42-
<<security-api-saml-logout,SAML logout API>>.
41+
<<security-api-saml-invalidate,SAML invalidate API>>,
42+
<<security-api-saml-logout,SAML logout API>>, and
43+
<<security-api-saml-complete-logout, SAML complete logout API>>.
4344

4445

4546
[[security-api-saml-authenticate-request-body]]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
[role="xpack"]
2+
[[security-api-saml-complete-logout]]
3+
=== SAML complete logout API
4+
++++
5+
<titleabbrev>SAML complete logout</titleabbrev>
6+
++++
7+
8+
Verifies the logout response sent from the SAML IdP.
9+
10+
NOTE: This API is intended for use by custom web applications other than {kib}.
11+
If you are using {kib}, see the <<saml-guide>>.
12+
13+
[[security-api-saml-complete-logout-request]]
14+
==== {api-request-title}
15+
16+
`POST /_security/saml/complete_logout`
17+
18+
[[security-api-saml-complete-logout-desc]]
19+
==== {api-description-title}
20+
21+
The SAML IdP may send a logout response back to the SP after handling
22+
the <<security-api-saml-logout,SP-initiated SAML Single Logout>>.
23+
This API verifies the response by ensuring the content is relevant
24+
and validating its signature. An empty response is returned if
25+
the verification process is successful.
26+
The response can be sent by the IdP with either the HTTP-Redirect or
27+
the HTTP-Post binding. The caller of this API must prepare the request
28+
accordingly so that this API can handle either of them.
29+
30+
{es} exposes all the necessary SAML related functionality via the SAML APIs.
31+
These APIs are used internally by {kib} in order to provide SAML based
32+
authentication, but can also be used by other custom web applications or other
33+
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
34+
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
35+
<<security-api-saml-invalidate,SAML invalidate API>>, and
36+
<<security-api-saml-logout,SAML logout API>>.
37+
38+
[[security-api-saml-complete-logout-request-body]]
39+
==== {api-request-body-title}
40+
41+
`realm`::
42+
(Required, string) The name of the SAML realm in {es} for which the configuration is
43+
used to verify the logout response.
44+
45+
`ids`::
46+
(Required, array) A json array with all the valid SAML Request Ids that the caller of
47+
the API has for the current user.
48+
49+
`queryString`::
50+
(Optional, string) If the SAML IdP sends the logout response with the HTTP-Redirect
51+
binding, this field must be set to the query string of the redirect URI.
52+
53+
`content`::
54+
(Optional, string) If the SAML IdP sends the logout response with the HTTP-Post
55+
binding, this field must be set to the value of the `SAMLResponse` form parameter
56+
from the logout response.
57+
58+
[[security-api-saml-complete-logout-example]]
59+
==== {api-examples-title}
60+
61+
The following example verifies the logout response sent by the SAML IdP
62+
using the HTTP-Redirect binding:
63+
64+
[source,console]
65+
--------------------------------------------------
66+
POST /_security/saml/complete_logout
67+
{
68+
"realm": "saml1",
69+
"ids": [ "_1c368075e0b3..." ],
70+
"queryString": "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK..."
71+
}
72+
--------------------------------------------------
73+
// TEST[skip:can't test this without a valid SAML Logout Response]
74+
75+
If the logout response is sent with the HTTP-Post binding, it can be verified
76+
as the follows:
77+
78+
[source,console]
79+
--------------------------------------------------
80+
POST /_security/saml/complete_logout
81+
{
82+
"realm": "saml1",
83+
"ids": [ "_1c368075e0b3..." ],
84+
"content": "PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46..."
85+
}
86+
--------------------------------------------------
87+
// TEST[skip:can't test this without a valid SAML Logout Response]
88+
89+
The API returns an empty response on success.

x-pack/docs/en/rest-api/security/saml-invalidate-api.asciidoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ These APIs are used internally by {kib} in order to provide SAML based
3030
authentication, but can also be used by other custom web applications or other
3131
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
3232
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
33-
and <<security-api-saml-logout,SAML logout API>>.
33+
<<security-api-saml-logout,SAML logout API>>, and
34+
<<security-api-saml-complete-logout, SAML complete logout API>>.
3435

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

42-
`queryString`::
43+
`queryString`::
4344
(Required, string) The query part of the URL that the user was redirected to by the SAML
4445
IdP to initiate the Single Logout. This query should include a single
4546
parameter named `SAMLRequest` that contains a SAML logout request that is
46-
deflated and Base64 encoded. If the SAML IdP has signed the logout request,
47+
deflated and Base64 encoded. If the SAML IdP has signed the logout request,
4748
the URL should include two extra parameters named `SigAlg` and `Signature`
4849
that contain the algorithm used for the signature and the signature value itself.
4950
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.
@@ -54,12 +55,12 @@ The client application must not attempt to parse or process the string in any wa
5455
either this parameter or the `acs` parameter.
5556

5657
[[security-api-saml-invalidate-response-body]]
57-
==== {api-response-body-title}
58+
==== {api-response-body-title}
5859

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

62-
`realm`::
63+
`realm`::
6364
(string) The realm name of the SAML realm in {es} that authenticated the user.
6465

6566
`redirect`::

x-pack/docs/en/rest-api/security/saml-logout-api.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ These APIs are used internally by {kib} in order to provide SAML based
3030
authentication, but can also be used by other custom web applications or other
3131
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
3232
<<security-api-saml-prepare-authentication,SAML prepare authentication API>>,
33-
and <<security-api-saml-invalidate,SAML invalidate API>>.
33+
<<security-api-saml-invalidate,SAML invalidate API>>, and
34+
<<security-api-saml-complete-logout, SAML complete logout API>>.
3435

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

4950
[[security-api-saml-logout-response-body]]
50-
==== {api-response-body-title}
51+
==== {api-response-body-title}
5152

5253
`redirect`::
5354
(string) A URL that contains a SAML logout request as a parameter. The user

x-pack/docs/en/rest-api/security/saml-prepare-authentication-api.asciidoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ the authentication process (see <<security-api-saml-authenticate,SAML authentica
3434
These APIs are used internally by {kib} in order to provide SAML based
3535
authentication, but can also be used by other custom web applications or other
3636
clients. See also <<security-api-saml-authenticate,SAML authenticate API>>,
37-
<<security-api-saml-invalidate,SAML invalidate API>>, and
38-
<<security-api-saml-logout,SAML logout API>>.
37+
<<security-api-saml-invalidate,SAML invalidate API>>,
38+
<<security-api-saml-logout,SAML logout API>>, and
39+
<<security-api-saml-complete-logout, SAML complete logout API>>.
3940

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

5354
[[security-api-saml-prepare-authentication-response-body]]
54-
==== {api-response-body-title}
55+
==== {api-response-body-title}
5556

5657
`id`::
5758
(string) A unique identifier for the SAML Request to be stored by the caller

x-pack/docs/en/security/authentication/saml-guide.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,3 +1037,6 @@ POST /_security/saml/invalidate
10371037
The custom web application will then need to also handle the response, which will include a `redirect`
10381038
parameter with a URL in the IdP that contains the SAML Logout response. The application should redirect the user
10391039
there to complete the logout.
1040+
1041+
For SP-initiated Single Logout, the IdP may send back a logout response which can be verified by {es}
1042+
using the <<security-api-saml-complete-logout,SAML complete logout API>>.

0 commit comments

Comments
 (0)