Skip to content

Commit bc51d8b

Browse files
committed
Add examples for security SAML APIs
1 parent 32b313f commit bc51d8b

File tree

29 files changed

+342
-122
lines changed

29 files changed

+342
-122
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 41 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 60 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_doc_ids/table.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,10 @@ security-api-suggest,https://www.elastic.co/guide/en/elasticsearch/reference/{br
672672
security-api-cross-cluster-key-update,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-cross-cluster-api-key.html
673673
security-api-update-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-api-key.html
674674
security-api-update-user-data,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-user-profile-data.html
675-
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
676675
security-api-update-settings,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-settings.html
677676
security-encrypt-internode,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-basic-setup.html#encrypt-internode-communication
677+
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
678+
security-saml-guide,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/saml-guide-stack.html
678679
service-accounts,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/service-accounts.html
679680
set-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/set-processor.html
680681
shape,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/shape.html

specification/security/saml_authenticate/Request.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,25 @@ import { Ids } from '@_types/common'
2323
/**
2424
* Authenticate SAML.
2525
*
26-
* Submits a SAML response message to Elasticsearch for consumption.
26+
* Submit a SAML response message to Elasticsearch for consumption.
27+
*
28+
* NOTE: This API is intended for use by custom web applications other than Kibana.
29+
* If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.
30+
*
31+
* The SAML message that is submitted can be:
32+
*
33+
* * A response to a SAML authentication request that was previously created using the SAML prepare authentication API.
34+
* * An unsolicited SAML message in the case of an IdP-initiated single sign-on (SSO) flow.
35+
*
36+
* In either case, the SAML message needs to be a base64 encoded XML document with a root element of `<Response>`.
37+
*
38+
* After successful validation, Elasticsearch responds with an Elasticsearch internal access token and refresh token that can be subsequently used for authentication.
39+
* This API endpoint essentially exchanges SAML responses that indicate successful authentication in the IdP for Elasticsearch access and refresh tokens, which can be used for authentication against Elasticsearch.
2740
* @rest_spec_name security.saml_authenticate
2841
* @availability stack since=7.5.0 stability=stable
2942
* @availability serverless stability=stable visibility=private
3043
* @doc_id security-api-saml-authenticate
44+
* @ext_doc_id security-saml-guide
3145
*/
3246
export interface Request extends RequestBase {
3347
urls: [
@@ -37,9 +51,9 @@ export interface Request extends RequestBase {
3751
}
3852
]
3953
body: {
40-
/** The SAML response as it was sent by the users browser, usually a Base64 encoded XML document. */
54+
/** The SAML response as it was sent by the user's browser, usually a Base64 encoded XML document. */
4155
content: string
42-
/** A json array with all the valid SAML Request Ids that the caller of the API has for the current user. */
56+
/** A JSON array with all the valid SAML Request Ids that the caller of the API has for the current user. */
4357
ids: Ids
4458
/** The name of the realm that should authenticate the SAML response. Useful in cases where many SAML realms are defined. */
4559
realm?: string

specification/security/saml_authenticate/Response.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,25 @@ import { integer } from '@_types/Numeric'
2121

2222
export class Response {
2323
body: {
24+
/**
25+
* The access token that was generated by Elasticsearch.
26+
*/
2427
access_token: string
28+
/**
29+
* The authenticated user's name.
30+
*/
2531
username: string
32+
/**
33+
* The amount of time (in seconds) left until the token expires.
34+
*/
2635
expires_in: integer
36+
/**
37+
* The refresh token that was generated by Elasticsearch.
38+
*/
2739
refresh_token: string
40+
/**
41+
* The name of the realm where the user was authenticated.
42+
*/
2843
realm: string
2944
}
3045
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary:
2+
# method_request: POST /_security/saml/authenticate
3+
description: >
4+
Run `POST /_security/saml/authenticate` to exchange a SAML Response indicating a successful authentication at the SAML IdP for an Elasticsearch access token and refresh token to be used in subsequent requests.
5+
# type: request
6+
value: |-
7+
{
8+
"content" : "PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....",
9+
"ids" : ["4fee3b046395c4e751011e97f8900b5273d56685"]
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# summary:
2+
description: A successful response from `POST /_security/saml/authenticate`.
3+
# type: response
4+
# response_code:
5+
value: |-
6+
{
7+
"access_token" : "46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3",
8+
"username" : "Bearer",
9+
"expires_in" : 1200,
10+
"refresh_token": "mJdXLtmvTUSpoLwMvdBt_w",
11+
"realm": "saml1"
12+
}

specification/security/saml_complete_logout/Request.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,20 @@ import { Ids } from '@_types/common'
2424
* Logout of SAML completely.
2525
*
2626
* Verifies the logout response sent from the SAML IdP.
27+
*
28+
* NOTE: This API is intended for use by custom web applications other than Kibana.
29+
* If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.
30+
*
31+
* The SAML IdP may send a logout response back to the SP after handling the SP-initiated SAML Single Logout.
32+
* This API verifies the response by ensuring the content is relevant and validating its signature.
33+
* An empty response is returned if the verification process is successful.
34+
* The response can be sent by the IdP with either the HTTP-Redirect or the HTTP-Post binding.
35+
* The caller of this API must prepare the request accordingly so that this API can handle either of them.
2736
* @rest_spec_name security.saml_complete_logout
2837
* @availability stack since=7.14.0 stability=stable
2938
* @availability serverless stability=stable visibility=private
3039
* @doc_id security-api-saml-complete-logout
40+
* @ext_doc_id security-saml-guide
3141
*/
3242
export interface Request extends RequestBase {
3343
urls: [
@@ -39,9 +49,11 @@ export interface Request extends RequestBase {
3949
body: {
4050
/** The name of the SAML realm in Elasticsearch for which the configuration is used to verify the logout response. */
4151
realm: string
42-
/** A json array with all the valid SAML Request Ids that the caller of the API has for the current user. */
52+
/** A JSON array with all the valid SAML Request Ids that the caller of the API has for the current user. */
4353
ids: Ids
44-
/** 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. */
54+
/**
55+
* 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.
56+
*/
4557
query_string?: string
4658
/** 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. */
4759
content?: string

specification/security/saml_complete_logout/Response.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020
import { Void } from '@spec_utils/VoidValue'
2121

2222
export class Response {
23+
/**
24+
* The API returns an empty response on success.
25+
*/
2326
body: Void
2427
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: HTTP-Redirect binding
2+
# method_request: POST /_security/saml/complete_logout
3+
description: >
4+
Run `POST /_security/saml/complete_logout` to verify the logout response sent by the SAML IdP using the HTTP-Redirect binding.
5+
# type: request
6+
value: |-
7+
{
8+
"realm": "saml1",
9+
"ids": [ "_1c368075e0b3..." ],
10+
"query_string": "SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK..."
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: HTTP-Post binding
2+
# method_request: POST /_security/saml/complete_logout
3+
description: >
4+
Run `POST /_security/saml/complete_logout` to verify the logout response sent by the SAML IdP using the HTTP-Post binding.
5+
# type: request
6+
value: |-
7+
{
8+
"realm": "saml1",
9+
"ids": [ "_1c368075e0b3..." ],
10+
"content": "PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46..."
11+
}

specification/security/saml_invalidate/Request.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ import { RequestBase } from '@_types/Base'
2222
/**
2323
* Invalidate SAML.
2424
*
25-
* Submits a SAML LogoutRequest message to Elasticsearch for consumption.
25+
* Submit a SAML LogoutRequest message to Elasticsearch for consumption.
26+
*
27+
* NOTE: This API is intended for use by custom web applications other than Kibana.
28+
* If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.
29+
*
30+
* The logout request comes from the SAML IdP during an IdP initiated Single Logout.
31+
* The custom web application can use this API to have Elasticsearch process the `LogoutRequest`.
32+
* After successful validation of the request, Elasticsearch invalidates the access token and refresh token that corresponds to that specific SAML principal and provides a URL that contains a SAML LogoutResponse message.
33+
* Thus the user can be redirected back to their IdP.
2634
* @rest_spec_name security.saml_invalidate
2735
* @availability stack since=7.5.0 stability=stable
2836
* @availability serverless stability=stable visibility=private
2937
* @doc_id security-api-saml-invalidate
38+
* @ext_doc_id security-saml-guide
3039
*/
3140
export interface Request extends RequestBase {
3241
urls: [
@@ -36,17 +45,17 @@ export interface Request extends RequestBase {
3645
}
3746
]
3847
body: {
39-
/** The Assertion Consumer Service URL that matches the one of the SAML realm in Elasticsearch that should be used. You must specify either this parameter or the realm parameter. */
48+
/** The Assertion Consumer Service URL that matches the one of the SAML realm in Elasticsearch that should be used. You must specify either this parameter or the `realm` parameter. */
4049
acs?: string
4150
/**
4251
* The query part of the URL that the user was redirected to by the SAML IdP to initiate the Single Logout.
43-
* This query should include a single parameter named SAMLRequest that contains a SAML logout request that is deflated and Base64 encoded.
44-
* 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.
45-
* In order for Elasticsearch to be able to verify the IdPs signature, the value of the query_string field must be an exact match to the string provided by the browser.
52+
* This query should include a single parameter named `SAMLRequest` that contains a SAML logout request that is deflated and Base64 encoded.
53+
* 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.
54+
* In order for Elasticsearch to be able to verify the IdP's signature, the value of the `query_string` field must be an exact match to the string provided by the browser.
4655
* The client application must not attempt to parse or process the string in any way.
4756
*/
4857
query_string: string
49-
/** The name of the SAML realm in Elasticsearch the configuration. You must specify either this parameter or the acs parameter. */
58+
/** The name of the SAML realm in Elasticsearch the configuration. You must specify either this parameter or the `acs` parameter. */
5059
realm?: string
5160
}
5261
}

specification/security/saml_invalidate/Response.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ import { integer } from '@_types/Numeric'
2121

2222
export class Response {
2323
body: {
24+
/**
25+
* The number of tokens that were invalidated as part of this logout.
26+
*/
2427
invalidated: integer
28+
/**
29+
* The realm name of the SAML realm in Elasticsearch that authenticated the user.
30+
*/
2531
realm: string
32+
/**
33+
* A SAML logout response as a parameter so that the user can be redirected back to the SAML IdP.
34+
*/
2635
redirect: string
2736
}
2837
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary:
2+
# method_request: POST /_security/saml/invalidate
3+
description: >
4+
Run `POST /_security/saml/invalidate` to invalidate all the tokens for realm `saml1` pertaining to the user that is identified in the SAML Logout Request.
5+
# type: request
6+
value: |-
7+
{
8+
"query_string" : "SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D",
9+
"realm" : "saml1"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary:
2+
description: A successful response from `POST /_security/saml/invalidate`.
3+
# type: response
4+
# response_code:
5+
value: |-
6+
{
7+
"redirect" : "https://my-idp.org/logout/SAMLResponse=....",
8+
"invalidated" : 2,
9+
"realm" : "saml1"
10+
}

specification/security/saml_logout/Request.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ import { RequestBase } from '@_types/Base'
2323
* Logout of SAML.
2424
*
2525
* Submits a request to invalidate an access token and refresh token.
26+
*
27+
* NOTE: This API is intended for use by custom web applications other than Kibana.
28+
* If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.
29+
*
30+
* This API invalidates the tokens that were generated for a user by the SAML authenticate API.
31+
* If the SAML realm in Elasticsearch is configured accordingly and the SAML IdP supports this, the Elasticsearch response contains a URL to redirect the user to the IdP that contains a SAML logout request (starting an SP-initiated SAML Single Logout).
2632
* @rest_spec_name security.saml_logout
2733
* @availability stack since=7.5.0 stability=stable
2834
* @availability serverless stability=stable visibility=private
2935
* @doc_id security-api-saml-logout
36+
* @ext_doc_id security-saml-guide
3037
*/
3138
export interface Request extends RequestBase {
3239
urls: [
@@ -38,7 +45,7 @@ export interface Request extends RequestBase {
3845
body: {
3946
/**
4047
* The access token that was returned as a response to calling the SAML authenticate API.
41-
* Alternatively, the most recent token that was received after refreshing the original one by using a refresh_token.
48+
* Alternatively, the most recent token that was received after refreshing the original one by using a `refresh_token`.
4249
*/
4350
token: string
4451
/**

specification/security/saml_logout/Response.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
export class Response {
2121
body: {
22+
/**
23+
* A URL that contains a SAML logout request as a parameter.
24+
* You can use this URL to be redirected back to the SAML IdP and to initiate Single Logout.
25+
*/
2226
redirect: string
2327
}
2428
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# summary:
2+
# method_request: POST /_security/saml/logout
3+
description: >
4+
Run `POST /_security/saml/logout` to invalidate the pair of tokens that were generated by calling the SAML authenticate API with a successful SAML response.
5+
# type: request
6+
value: |-
7+
{
8+
"token" : "46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3",
9+
"refresh_token" : "mJdXLtmvTUSpoLwMvdBt_w"
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# summary:
2+
description: A successful response from `POST /_security/saml/logout`.
3+
# type: response
4+
# response_code:
5+
value: |-
6+
{
7+
"redirect" : "https://my-idp.org/logout/SAMLRequest=...."
8+
}

specification/security/saml_prepare_authentication/Request.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@ import { RequestBase } from '@_types/Base'
2222
/**
2323
* Prepare SAML authentication.
2424
*
25-
* Creates a SAML authentication request (`<AuthnRequest>`) as a URL string, based on the configuration of the respective SAML realm in Elasticsearch.
25+
* Create a SAML authentication request (`<AuthnRequest>`) as a URL string based on the configuration of the respective SAML realm in Elasticsearch.
26+
*
27+
* NOTE: This API is intended for use by custom web applications other than Kibana.
28+
* If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.
29+
*
30+
* This API returns a URL pointing to the SAML Identity Provider.
31+
* You can use the URL to redirect the browser of the user in order to continue the authentication process.
32+
* The URL includes a single parameter named `SAMLRequest`, which contains a SAML Authentication request that is deflated and Base64 encoded.
33+
* If the configuration dictates that SAML authentication requests should be signed, the URL has two extra parameters named `SigAlg` and `Signature`.
34+
* These parameters contain the algorithm used for the signature and the signature value itself.
35+
* It also returns a random string that uniquely identifies this SAML Authentication request.
36+
* The caller of this API needs to store this identifier as it needs to be used in a following step of the authentication process.
2637
* @rest_spec_name security.saml_prepare_authentication
2738
* @availability stack since=7.5.0 stability=stable
2839
* @availability serverless stability=stable visibility=private
2940
* @doc_id security-api-saml-prepare-authentication
41+
* @ext_doc_id security-saml-guide
3042
*/
3143
export interface Request extends RequestBase {
3244
urls: [
@@ -38,16 +50,16 @@ export interface Request extends RequestBase {
3850
body: {
3951
/**
4052
* The Assertion Consumer Service URL that matches the one of the SAML realms in Elasticsearch.
41-
* The realm is used to generate the authentication request. You must specify either this parameter or the realm parameter.
53+
* The realm is used to generate the authentication request. You must specify either this parameter or the `realm` parameter.
4254
*/
4355
acs?: string
4456
/**
4557
* The name of the SAML realm in Elasticsearch for which the configuration is used to generate the authentication request.
46-
* You must specify either this parameter or the acs parameter.
58+
* You must specify either this parameter or the `acs` parameter.
4759
*/
4860
realm?: string
4961
/**
50-
* A string that will be included in the redirect URL that this API returns as the RelayState query parameter.
62+
* A string that will be included in the redirect URL that this API returns as the `RelayState` query parameter.
5163
* If the Authentication Request is signed, this value is used as part of the signature computation.
5264
*/
5365
relay_state?: string

specification/security/saml_prepare_authentication/Response.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ import { Id } from '@_types/common'
2121

2222
export class Response {
2323
body: {
24+
/**
25+
* A unique identifier for the SAML Request to be stored by the caller of the API.
26+
*/
2427
id: Id
28+
/**
29+
* The name of the Elasticsearch realm that was used to construct the authentication request.
30+
*/
2531
realm: string
32+
/**
33+
* The URL to redirect the user to.
34+
*/
2635
redirect: string
2736
}
2837
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
summary: Prepare with a realm
2+
# method_request: POST /_security/saml/prepare
3+
description: >
4+
Run `POST /_security/saml/prepare` to generate a SAML authentication request for the SAML realm named `saml1`.
5+
# type: request
6+
value: |-
7+
{
8+
"realm" : "saml1"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
summary: Prepare with an ACS
2+
# method_request: POST /_security/saml/prepare
3+
description: >
4+
Run `POST /_security/saml/prepare` to generate a SAML authentication request for the SAML realm with an Assertion Consuming Service (ACS) URL.
5+
# type: request
6+
value: |-
7+
{
8+
"acs" : "https://kibana.org/api/security/saml/callback"
9+
}

0 commit comments

Comments
 (0)