Skip to content

Commit 697d2aa

Browse files
committed
Add examples for security SAML APIs
1 parent 97b7b79 commit 697d2aa

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
@@ -669,9 +669,10 @@ security-api-suggest,https://www.elastic.co/guide/en/elasticsearch/reference/{br
669669
security-api-cross-cluster-key-update,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-cross-cluster-api-key.html
670670
security-api-update-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-api-key.html
671671
security-api-update-user-data,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-user-profile-data.html
672-
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
673672
security-api-update-settings,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-settings.html
674673
security-encrypt-internode,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-basic-setup.html#encrypt-internode-communication
674+
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
675+
security-saml-guide,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/saml-guide-stack.html
675676
service-accounts,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/service-accounts.html
676677
set-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/set-processor.html
677678
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,17 +23,31 @@ 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
body: {
34-
/** The SAML response as it was sent by the users browser, usually a Base64 encoded XML document. */
48+
/** The SAML response as it was sent by the user's browser, usually a Base64 encoded XML document. */
3549
content: string
36-
/** A json array with all the valid SAML Request Ids that the caller of the API has for the current user. */
50+
/** A JSON array with all the valid SAML Request Ids that the caller of the API has for the current user. */
3751
ids: Ids
3852
/** The name of the realm that should authenticate the SAML response. Useful in cases where many SAML realms are defined. */
3953
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,18 +24,30 @@ 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
body: {
3444
/** The name of the SAML realm in Elasticsearch for which the configuration is used to verify the logout response. */
3545
realm: string
36-
/** A json array with all the valid SAML Request Ids that the caller of the API has for the current user. */
46+
/** A JSON array with all the valid SAML Request Ids that the caller of the API has for the current user. */
3747
ids: Ids
38-
/** 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. */
48+
/**
49+
* 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.
50+
*/
3951
query_string?: string
4052
/** 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. */
4153
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+
}

0 commit comments

Comments
 (0)