Skip to content

Commit 0acbe74

Browse files
authored
[DOCS] Add examples for security user profile and SAML APIs (#3520) (#3533)
(cherry picked from commit 72c9fef)
1 parent b628c5a commit 0acbe74

File tree

49 files changed

+750
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+750
-177
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 72 additions & 39 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: 138 additions & 93 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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,17 @@ security-api-clear-role-cache,https://www.elastic.co/guide/en/elasticsearch/refe
609609
security-api-clear-service-token-caches,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-clear-service-token-caches.html
610610
security-api-create-api-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-create-api-key.html
611611
security-api-create-service-token,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-create-service-token.html
612+
security-api-cross-cluster-key-update,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-cross-cluster-api-key.html
612613
security-api-delegate-pki,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delegate-pki-authentication.html
613614
security-api-delete-privilege,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delete-privilege.html
614615
security-api-delete-role-mapping,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delete-role-mapping.html
615616
security-api-delete-role,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delete-role.html
616617
security-api-delete-service-token,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delete-service-token.html
617618
security-api-delete-user,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-delete-user.html
618619
security-api-disable-user,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-disable-user.html
620+
security-api-disable-user-profile,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-disable-user-profile.html
619621
security-api-enable-user,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-enable-user.html
622+
security-api-enable-user-profile,https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user-profile.html
620623
security-api-get-api-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-api-key.html
621624
security-api-get-builtin-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-builtin-privileges.html
622625
security-api-get-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-privileges.html
@@ -628,8 +631,10 @@ security-api-get-settings,https://www.elastic.co/guide/en/elasticsearch/referenc
628631
security-api-get-token,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-token.html
629632
security-api-get-user-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-user-privileges.html
630633
security-api-get-user,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-user.html
634+
security-api-get-user-profile,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-get-user-profile.html
631635
security-api-grant-api-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-grant-api-key.html
632636
security-api-has-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-has-privileges.html
637+
security-api-has-privileges-user-profile,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-has-privileges-user-profile.html
633638
security-api-invalidate-api-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-invalidate-api-key.html
634639
security-api-invalidate-token,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-invalidate-token.html
635640
security-api-kibana-enrollment,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-kibana-enrollment.html
@@ -649,8 +654,13 @@ security-api-saml-logout,https://www.elastic.co/guide/en/elasticsearch/reference
649654
security-api-saml-prepare-authentication,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-saml-prepare-authentication.html
650655
security-api-saml-sp-metadata,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-saml-sp-metadata.html
651656
security-api-ssl,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-ssl.html
652-
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
657+
security-api-suggest,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-suggest-user-profile.html
658+
security-api-update-key,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-api-key.html
653659
security-api-update-settings,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-settings.html
660+
security-api-update-user-data,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-api-update-user-profile-data.html
661+
security-encrypt-internode,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-basic-setup.html#encrypt-internode-communication
662+
security-privileges,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/security-privileges.html
663+
security-saml-guide,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/saml-guide-stack.html
654664
service-accounts,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/service-accounts.html
655665
set-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/set-processor.html
656666
shape,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/shape.html

specification/security/_types/GrantType.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export enum GrantType {
2424
password,
2525
/**
2626
* In this type of grant, you must supply an access token that was created by the Elasticsearch token service.
27+
* If you are activating a user profile, you can alternatively supply a JWT (either a JWT `access_token` or a JWT `id_token`).
2728
*/
2829
access_token
2930
}

specification/security/activate_user_profile/Request.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,46 @@ import { RequestBase } from '@_types/Base'
2424
* Activate a user profile.
2525
*
2626
* Create or update a user profile on behalf of another user.
27+
*
28+
* NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
29+
* Individual users and external applications should not call this API directly.
30+
* The calling application must have either an `access_token` or a combination of `username` and `password` for the user that the profile document is intended for.
31+
* Elastic reserves the right to change or remove this feature in future releases without prior notice.
32+
*
33+
* This API creates or updates a profile document for end users with information that is extracted from the user's authentication object including `username`, `full_name,` `roles`, and the authentication realm.
34+
* For example, in the JWT `access_token` case, the profile user's `username` is extracted from the JWT token claim pointed to by the `claims.principal` setting of the JWT realm that authenticated the token.
35+
*
36+
* When updating a profile document, the API enables the document if it was disabled.
37+
* Any updates do not change existing content for either the `labels` or `data` fields.
2738
* @rest_spec_name security.activate_user_profile
2839
* @availability stack since=8.2.0 stability=stable
2940
* @availability serverless stability=stable visibility=private
3041
* @cluster_privileges manage_user_profile
3142
*/
3243
export interface Request extends RequestBase {
3344
body: {
45+
/**
46+
* The user's Elasticsearch access token or JWT.
47+
* Both `access` and `id` JWT token types are supported and they depend on the underlying JWT realm configuration.
48+
* If you specify the `access_token` grant type, this parameter is required.
49+
* It is not valid with other grant types.
50+
*/
3451
access_token?: string
52+
/**
53+
* The type of grant.
54+
*/
3555
grant_type: GrantType
56+
/**
57+
* The user's password.
58+
* If you specify the `password` grant type, this parameter is required.
59+
* It is not valid with other grant types.
60+
*/
3661
password?: string
62+
/**
63+
* The username that identifies the user.
64+
* If you specify the `password` grant type, this parameter is required.
65+
* It is not valid with other grant types.
66+
*/
3767
username?: string
3868
}
3969
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# summary:
2+
# method_request: POST /_security/profile/_activate
3+
description: >
4+
Run `POST /_security/profile/_activate` to activate a user profile.
5+
# type: request
6+
value: |-
7+
{
8+
"grant_type": "password",
9+
"username" : "jacknich",
10+
"password" : "l0ng-r4nd0m-p@ssw0rd"
11+
}

specification/security/disable_user_profile/Request.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ import { Refresh } from '@_types/common'
2525
* Disable a user profile.
2626
*
2727
* Disable user profiles so that they are not visible in user profile searches.
28+
*
29+
* NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
30+
* Individual users and external applications should not call this API directly.
31+
* Elastic reserves the right to change or remove this feature in future releases without prior notice.
32+
*
33+
* When you activate a user profile, its automatically enabled and visible in user profile searches. You can use the disable user profile API to disable a user profile so it’s not visible in these searches.
34+
* To re-enable a disabled user profile, use the enable user profile API .
2835
* @rest_spec_name security.disable_user_profile
2936
* @availability stack since=8.2.0 stability=stable
3037
* @availability serverless stability=stable visibility=private
3138
* @cluster_privileges manage_user_profile
39+
* @doc_id security-api-disable-user-profile
3240
*/
3341
export interface Request extends RequestBase {
3442
path_parts: {
@@ -39,9 +47,9 @@ export interface Request extends RequestBase {
3947
}
4048
query_parameters: {
4149
/**
42-
* If 'true', Elasticsearch refreshes the affected shards to make this operation
43-
* visible to search, if 'wait_for' then wait for a refresh to make this operation
44-
* visible to search, if 'false' do nothing with refreshes.
50+
* If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search.
51+
* If 'wait_for', it waits for a refresh to make this operation visible to search.
52+
* If 'false', it does nothing with refreshes.
4553
* @server_default false
4654
*/
4755
refresh?: Refresh

specification/security/enable_user_profile/Request.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,32 @@ import { Refresh } from '@_types/common'
2525
* Enable a user profile.
2626
*
2727
* Enable user profiles to make them visible in user profile searches.
28+
*
29+
* NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
30+
* Individual users and external applications should not call this API directly.
31+
* Elastic reserves the right to change or remove this feature in future releases without prior notice.
32+
*
33+
* When you activate a user profile, it's automatically enabled and visible in user profile searches.
34+
* If you later disable the user profile, you can use the enable user profile API to make the profile visible in these searches again.
2835
* @rest_spec_name security.enable_user_profile
2936
* @availability stack since=8.2.0 stability=stable
3037
* @availability serverless stability=stable visibility=private
3138
* @cluster_privileges manage_user_profile
39+
* @doc_id security-api-enable-user-profile
3240
*/
3341
export interface Request extends RequestBase {
3442
path_parts: {
3543
/**
36-
* Unique identifier for the user profile.
44+
* A unique identifier for the user profile.
3745
*/
3846
uid: UserProfileId
3947
}
4048
query_parameters: {
4149
/**
4250
* If 'true', Elasticsearch refreshes the affected shards to make this operation
43-
* visible to search, if 'wait_for' then wait for a refresh to make this operation
44-
* visible to search, if 'false' do nothing with refreshes.
51+
* visible to search.
52+
* If 'wait_for', it waits for a refresh to make this operation visible to search.
53+
* If 'false', nothing is done with refreshes.
4554
* @server_default false
4655
*/
4756
refresh?: Refresh

specification/security/get_user_profile/Request.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ import { RequestBase } from '@_types/Base'
2424
* Get a user profile.
2525
*
2626
* Get a user's profile using the unique profile ID.
27+
*
28+
* NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
29+
* Individual users and external applications should not call this API directly.
30+
* Elastic reserves the right to change or remove this feature in future releases without prior notice.
2731
* @rest_spec_name security.get_user_profile
2832
* @availability stack since=8.2.0 stability=stable
2933
* @availability serverless stability=stable visibility=private
30-
* @cluster_privileges manage_user_profile
34+
* @cluster_privileges read_security
35+
* @doc_id security-api-get-user-profile
3136
*/
3237
export interface Request extends RequestBase {
3338
path_parts: {
@@ -38,9 +43,9 @@ export interface Request extends RequestBase {
3843
}
3944
query_parameters: {
4045
/**
41-
* List of filters for the `data` field of the profile document.
42-
* To return all content use `data=*`. To return a subset of content
43-
* use `data=<key>` to retrieve content nested under the specified `<key>`.
46+
* A comma-separated list of filters for the `data` field of the profile document.
47+
* To return all content use `data=*`.
48+
* To return a subset of content use `data=<key>` to retrieve content nested under the specified `<key>`.
4449
* By default returns no `data` content.
4550
*/
4651
data?: string | string[]

specification/security/get_user_profile/Response.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import { GetUserProfileErrors } from './types'
2222

2323
export class Response {
2424
body: {
25+
/**
26+
* A successful call returns the JSON representation of the user profile and its internal versioning numbers.
27+
* The API returns an empty object if no profile document is found for the provided `uid`.
28+
* The content of the data field is not returned by default to avoid deserializing a potential large payload.
29+
*/
2530
profiles: UserProfileWithMetadata[]
2631
errors?: GetUserProfileErrors
2732
}

specification/security/has_privileges_user_profile/Request.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ import { PrivilegesCheck } from './types'
2525
* Check user profile privileges.
2626
*
2727
* Determine whether the users associated with the specified user profile IDs have all the requested privileges.
28+
*
29+
* NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. Individual users and external applications should not call this API directly.
30+
* Elastic reserves the right to change or remove this feature in future releases without prior notice.
2831
* @rest_spec_name security.has_privileges_user_profile
2932
* @availability stack since=8.3.0 stability=stable
3033
* @availability serverless stability=stable visibility=private
3134
* @cluster_privileges manage_user_profile
35+
* @doc_id security-api-has-privileges-user-profile
3236
* @ext_doc_id user-profile
3337
*/
3438
export interface Request extends RequestBase {
@@ -37,6 +41,9 @@ export interface Request extends RequestBase {
3741
* A list of profile IDs. The privileges are checked for associated users of the profiles.
3842
*/
3943
uids: UserProfileId[]
44+
/**
45+
* An object containing all the privileges to be checked.
46+
*/
4047
privileges: PrivilegesCheck
4148
}
4249
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# summary:
2+
# method_request: POST /_security/profile/_has_privileges
3+
description: >
4+
Run `POST /_security/profile/_has_privileges` to check whether the two users associated with the specified profiles have all the requested set of cluster, index, and application privileges.
5+
# type: request
6+
value: |-
7+
{
8+
"uids": [
9+
"u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0",
10+
"u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1",
11+
"u_does-not-exist_0"
12+
],
13+
"privileges": {
14+
"cluster": [ "monitor", "create_snapshot", "manage_ml" ],
15+
"index" : [
16+
{
17+
"names": [ "suppliers", "products" ],
18+
"privileges": [ "create_doc"]
19+
},
20+
{
21+
"names": [ "inventory" ],
22+
"privileges" : [ "read", "write" ]
23+
}
24+
],
25+
"application": [
26+
{
27+
"application": "inventory_manager",
28+
"privileges" : [ "read", "data:write/inventory" ],
29+
"resources" : [ "product/1852563" ]
30+
}
31+
]
32+
}
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# summary:
2+
description: >
3+
A response from `POST /_security/profile/_has_privileges` that indicates only one of the three users has all the privileges and one of them is not found.
4+
# type: response
5+
# response_code:
6+
value: |-
7+
{
8+
"has_privilege_uids": ["u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1"],
9+
"errors": {
10+
"count": 1,
11+
"details": {
12+
"u_does-not-exist_0": {
13+
"type": "resource_not_found_exception",
14+
"reason": "profile document not found"
15+
}
16+
}
17+
}
18+
}

specification/security/saml_authenticate/Request.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +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
43+
* @doc_id security-api-saml-authenticate
44+
* @ext_doc_id security-saml-guide
3045
*/
3146
export interface Request extends RequestBase {
3247
body: {
33-
/** 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. */
3449
content: string
35-
/** 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. */
3651
ids: Ids
3752
/** The name of the realm that should authenticate the SAML response. Useful in cases where many SAML realms are defined. */
3853
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+
}

0 commit comments

Comments
 (0)