Skip to content

Commit 97b7b79

Browse files
committed
Add examples for security user profile APIs
1 parent ca1a23f commit 97b7b79

File tree

23 files changed

+411
-106
lines changed

23 files changed

+411
-106
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 31 additions & 25 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: 54 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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,6 +24,17 @@ 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
@@ -32,9 +43,28 @@ import { RequestBase } from '@_types/Base'
3243
*/
3344
export interface Request extends RequestBase {
3445
body: {
46+
/**
47+
* The user's Elasticsearch access token or JWT.
48+
* Both `access` and `id` JWT token types are supported and they depend on the underlying JWT realm configuration.
49+
* If you specify the `access_token` grant type, this parameter is required.
50+
* It is not valid with other grant types.
51+
*/
3552
access_token?: string
53+
/**
54+
* The type of grant.
55+
*/
3656
grant_type: GrantType
57+
/**
58+
* The user's password.
59+
* If you specify the `password` grant type, this parameter is required.
60+
* It is not valid with other grant types.
61+
*/
3762
password?: string
63+
/**
64+
* The username that identifies the user.
65+
* If you specify the `password` grant type, this parameter is required.
66+
* It is not valid with other grant types.
67+
*/
3868
username?: string
3969
}
4070
}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# summary:
2-
# method_request: POST /_security/user/jacknich
2+
# method_request: POST /_security/profile/_activate
33
description: >
4-
Run `POST /_security/user/jacknich` to create a user.
4+
Run `POST /_security/profile/_activate` to activate a user profile.
55
# type: request
66
value: |-
77
{
8-
"password" : "l0ng-r4nd0m-p@ssw0rd",
9-
"roles" : [ "admin", "other_role1" ],
10-
"full_name" : "Jack Nicholson",
11-
"email" : "[email protected]",
12-
"metadata" : {
13-
"intelligence" : 7
14-
}
8+
"grant_type": "password",
9+
"username" : "jacknich",
10+
"password" : "l0ng-r4nd0m-p@ssw0rd"
1511
}

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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ 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
@@ -34,15 +41,16 @@ import { Refresh } from '@_types/common'
3441
export interface Request extends RequestBase {
3542
path_parts: {
3643
/**
37-
* Unique identifier for the user profile.
44+
* A unique identifier for the user profile.
3845
*/
3946
uid: UserProfileId
4047
}
4148
query_parameters: {
4249
/**
4350
* If 'true', Elasticsearch refreshes the affected shards to make this operation
44-
* visible to search, if 'wait_for' then wait for a refresh to make this operation
45-
* 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.
4654
* @server_default false
4755
*/
4856
refresh?: Refresh

specification/security/get_user_profile/Request.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ 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
3135
* @doc_id security-api-get-user-profile
3236
*/
3337
export interface Request extends RequestBase {
@@ -39,9 +43,9 @@ export interface Request extends RequestBase {
3943
}
4044
query_parameters: {
4145
/**
42-
* List of filters for the `data` field of the profile document.
43-
* To return all content use `data=*`. To return a subset of content
44-
* 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>`.
4549
* By default returns no `data` content.
4650
*/
4751
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ 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
@@ -38,6 +41,9 @@ export interface Request extends RequestBase {
3841
* A list of profile IDs. The privileges are checked for associated users of the profiles.
3942
*/
4043
uids: UserProfileId[]
44+
/**
45+
* An object containing all the privileges to be checked.
46+
*/
4147
privileges: PrivilegesCheck
4248
}
4349
}
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/suggest_user_profiles/Request.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import { Hint } from './types'
2525
* Suggest a user profile.
2626
*
2727
* Get suggestions for user profiles that match specified search criteria.
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.
2832
* @rest_spec_name security.suggest_user_profiles
2933
* @availability stack since=8.2.0 stability=stable
3034
* @availability serverless stability=stable visibility=private
@@ -34,36 +38,37 @@ import { Hint } from './types'
3438
export interface Request extends RequestBase {
3539
query_parameters: {
3640
/**
37-
* List of filters for the `data` field of the profile document.
38-
* To return all content use `data=*`. To return a subset of content
39-
* use `data=<key>` to retrieve content nested under the specified `<key>`.
40-
* By default returns no `data` content.
41+
* A comma-separated list of filters for the `data` field of the profile document.
42+
* To return all content use `data=*`.
43+
* To return a subset of content, use `data=<key>` to retrieve content nested under the specified `<key>`.
44+
* By default, the API returns no `data` content.
45+
* It is an error to specify `data` as both the query parameter and the request body field.
4146
*/
4247
data?: string | string[]
4348
}
4449
body: {
4550
/**
46-
* Query string used to match name-related fields in user profile documents.
51+
* A query string used to match name-related fields in user profile documents.
4752
* Name-related fields are the user's `username`, `full_name`, and `email`.
4853
*/
4954
name?: string
5055
/**
51-
* Number of profiles to return.
56+
* The number of profiles to return.
5257
* @server_default 10
5358
*/
5459
size?: long
5560
/**
56-
* List of filters for the `data` field of the profile document.
57-
* To return all content use `data=*`. To return a subset of content
58-
* use `data=<key>` to retrieve content nested under the specified `<key>`.
59-
* By default returns no `data` content.
61+
* A comma-separated list of filters for the `data` field of the profile document.
62+
* To return all content use `data=*`.
63+
* To return a subset of content, use `data=<key>` to retrieve content nested under the specified `<key>`.
64+
* By default, the API returns no `data` content.
65+
* It is an error to specify `data` as both the query parameter and the request body field.
6066
*/
6167
data?: string | string[]
6268
/**
6369
* Extra search criteria to improve relevance of the suggestion result.
6470
* Profiles matching the spcified hint are ranked higher in the response.
65-
* Profiles not matching the hint don't exclude the profile from the response
66-
* as long as the profile matches the `name` field query.
71+
* Profiles not matching the hint aren't excluded from the response as long as the profile matches the `name` field query.
6772
*/
6873
hint?: Hint
6974
}

specification/security/suggest_user_profiles/Response.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@ export class TotalUserProfiles {
2828

2929
export class Response {
3030
body: {
31+
/**
32+
* Metadata about the number of matching profiles.
33+
*/
3134
total: TotalUserProfiles
35+
/**
36+
* The number of milliseconds it took Elasticsearch to run the request.
37+
*/
3238
took: long
39+
/**
40+
* A list of profile documents, ordered by relevance, that match the search criteria.
41+
*/
3342
profiles: UserProfile[]
3443
}
3544
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# summary:
2+
# method_request: POST /_security/profile/_suggest
3+
description: >
4+
Run `POST /_security/profile/_suggest` to get suggestions for profile documents with name-related fields matching `jack`.
5+
It specifies both `uids` and `labels` hints for better relevance.
6+
The `labels` hint ranks profiles higher if their `direction` label matches either `north` or `east`.
7+
# type: request
8+
value: |-
9+
{
10+
"name": "jack",
11+
"hint": {
12+
"uids": [
13+
"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0",
14+
"u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0"
15+
],
16+
"labels": {
17+
"direction": ["north", "east"]
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)