Skip to content

Commit 1462ece

Browse files
tvernumlcawl
authored andcommitted
[DOCS] Add docs for Application Privileges (#32635)
1 parent 52c2181 commit 1462ece

File tree

13 files changed

+495
-30
lines changed

13 files changed

+495
-30
lines changed

docs/reference/redirects.asciidoc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,9 @@ native realm:
533533
You can use the following APIs to add, remove, and retrieve role mappings:
534534

535535
* <<security-api-put-role-mapping,Add role mappings>>, <<security-api-delete-role-mapping,Delete role mappings>>
536-
* <<security-api-get-role-mapping,Get role mappings>>
536+
* <<security-api-get-role-mapping,Get role mappings>>
537+
538+
[role="exclude",id="security-api-privileges"]
539+
=== Privilege APIs
540+
541+
See <<security-api-has-privileges>>.

x-pack/docs/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,22 @@ setups['jacknich_user'] = '''
750750
"metadata" : { "intelligence" : 7 }
751751
}
752752
'''
753+
setups['app0102_privileges'] = '''
754+
- do:
755+
xpack.security.put_privileges:
756+
body: >
757+
{
758+
"myapp": {
759+
"read": {
760+
"application": "myapp",
761+
"name": "read",
762+
"actions": [
763+
"data:read/*",
764+
"action:login" ],
765+
"metadata": {
766+
"description": "Read access to myapp"
767+
}
768+
}
769+
}
770+
}
771+
'''

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

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,85 @@ You can use the following APIs to perform {security} activities.
66

77
* <<security-api-authenticate>>
88
* <<security-api-clear-cache>>
9-
* <<security-api-privileges>>
9+
* <<security-api-has-privileges>>
1010
* <<security-api-ssl>>
1111

1212
[float]
13-
[[security-role-apis]]
14-
=== Roles
13+
[[security-api-app-privileges]]
14+
=== Application privileges
1515

16-
You can use the following APIs to add, remove, and retrieve roles in the native realm:
16+
You can use the following APIs to add, update, retrieve, and remove application
17+
privileges:
1718

18-
* <<security-api-put-role,Create role>>, <<security-api-delete-role,Delete role>>
19-
* <<security-api-clear-role-cache,Clear roles cache>>
20-
* <<security-api-get-role,Get roles>>
19+
* <<security-api-put-privileges,Create or update privileges>>
20+
* <<security-api-delete-privilege,Delete privileges>>
21+
* <<security-api-get-privileges,Get privileges>>
2122

2223
[float]
2324
[[security-role-mapping-apis]]
2425
=== Role mappings
2526

26-
You can use the following APIs to add, remove, and retrieve role mappings:
27+
You can use the following APIs to add, remove, update, and retrieve role mappings:
2728

28-
* <<security-api-put-role-mapping,Add role mappings>>, <<security-api-delete-role-mapping,Delete role mappings>>
29+
* <<security-api-put-role-mapping,Create or update role mappings>>
30+
* <<security-api-delete-role-mapping,Delete role mappings>>
2931
* <<security-api-get-role-mapping,Get role mappings>>
3032

33+
[float]
34+
[[security-role-apis]]
35+
=== Roles
36+
37+
You can use the following APIs to add, remove, update, and retrieve roles in the native realm:
38+
39+
* <<security-api-put-role,Create or update roles>>
40+
* <<security-api-clear-role-cache,Clear roles cache>>
41+
* <<security-api-delete-role,Delete roles>>
42+
* <<security-api-get-role,Get roles>>
43+
3144
[float]
3245
[[security-token-apis]]
3346
=== Tokens
3447

3548
You can use the following APIs to create and invalidate bearer tokens for access
3649
without requiring basic authentication:
3750

38-
* <<security-api-get-token,Get token>>, <<security-api-invalidate-token,Invalidate token>>
51+
* <<security-api-get-token,Get token>>
52+
* <<security-api-invalidate-token,Invalidate token>>
3953

4054
[float]
4155
[[security-user-apis]]
4256
=== Users
4357

44-
You can use the following APIs to create, read, update, and delete users from the
58+
You can use the following APIs to add, remove, update, or retrieve users in the
4559
native realm:
4660

47-
* <<security-api-put-user,Create users>>, <<security-api-delete-user,Delete users>>
48-
* <<security-api-enable-user,Enable users>>, <<security-api-disable-user,Disable users>>
61+
* <<security-api-put-user,Create or update users>>
4962
* <<security-api-change-password,Change passwords>>
63+
* <<security-api-delete-user,Delete users>>
64+
* <<security-api-disable-user,Disable users>>
65+
* <<security-api-enable-user,Enable users>>
5066
* <<security-api-get-user,Get users>>
5167

68+
69+
include::security/put-app-privileges.asciidoc[]
5270
include::security/authenticate.asciidoc[]
5371
include::security/change-password.asciidoc[]
5472
include::security/clear-cache.asciidoc[]
5573
include::security/create-role-mappings.asciidoc[]
5674
include::security/clear-roles-cache.asciidoc[]
5775
include::security/create-roles.asciidoc[]
5876
include::security/create-users.asciidoc[]
77+
include::security/delete-app-privileges.asciidoc[]
5978
include::security/delete-role-mappings.asciidoc[]
6079
include::security/delete-roles.asciidoc[]
6180
include::security/delete-tokens.asciidoc[]
6281
include::security/delete-users.asciidoc[]
6382
include::security/disable-users.asciidoc[]
6483
include::security/enable-users.asciidoc[]
84+
include::security/get-app-privileges.asciidoc[]
6585
include::security/get-role-mappings.asciidoc[]
6686
include::security/get-roles.asciidoc[]
6787
include::security/get-tokens.asciidoc[]
6888
include::security/get-users.asciidoc[]
69-
include::security/privileges.asciidoc[]
89+
include::security/has-privileges.asciidoc[]
7090
include::security/ssl.asciidoc[]

x-pack/docs/en/rest-api/security/create-role-mappings.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[role="xpack"]
22
[[security-api-put-role-mapping]]
3-
=== Add role mappings API
3+
=== Create or update role mappings API
44

5-
Adds and updates role mappings.
5+
Creates and updates role mappings.
66

77
==== Request
88

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[role="xpack"]
22
[[security-api-put-role]]
3-
=== Create roles API
3+
=== Create or update roles API
44

5-
Adds roles in the native realm.
5+
Adds and updates roles in the native realm.
66

77
==== Request
88

@@ -29,9 +29,20 @@ file-based role management. For more information about the native realm, see
2929
The following parameters can be specified in the body of a PUT or POST request
3030
and pertain to adding a role:
3131

32+
`applications`:: (list) A list of application privilege entries.
33+
`application` (required)::: (string) The name of the application to which this entry applies
34+
`privileges`::: (list) A list of strings, where each element is the name of an application
35+
privilege or action.
36+
`resources`::: (list) A list resources to which the privileges are applied.
37+
3238
`cluster`:: (list) A list of cluster privileges. These privileges define the
3339
cluster level actions that users with this role are able to execute.
3440

41+
`global`:: (object) An object defining global privileges. A global privilege is
42+
a form of cluster privilege that is request-aware. Support for global privileges
43+
is currently limited to the management of application privileges.
44+
This field is optional.
45+
3546
`indices`:: (list) A list of indices permissions entries.
3647
`field_security`::: (list) The document fields that the owners of the role have
3748
read access to. For more information, see
@@ -79,6 +90,13 @@ POST /_xpack/security/role/my_admin_role
7990
"query": "{\"match\": {\"title\": \"foo\"}}" // optional
8091
}
8192
],
93+
"applications": [
94+
{
95+
"application": "myapp",
96+
"privileges": [ "admin", "read" ],
97+
"resources": [ "*" ]
98+
}
99+
],
82100
"run_as": [ "other_user" ], // optional
83101
"metadata" : { // optional
84102
"version" : 1

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[role="xpack"]
22
[[security-api-put-user]]
3-
=== Create users API
3+
=== Create or update users API
44

5-
Creates and updates users in the native realm. These users are commonly referred
5+
Adds and updates users in the native realm. These users are commonly referred
66
to as _native users_.
77

88

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[role="xpack"]
2+
[[security-api-delete-privilege]]
3+
=== Delete application privileges API
4+
5+
Removes
6+
{stack-ov}/security-privileges.html#application-privileges[application privileges].
7+
8+
==== Request
9+
10+
`DELETE /_xpack/security/privilege/<application>/<privilege>`
11+
12+
//==== Description
13+
14+
==== Path Parameters
15+
16+
`application` (required)::
17+
(string) The name of the application. Application privileges are always
18+
associated with exactly one application.
19+
20+
`privilege` (required)::
21+
(string) The name of the privilege.
22+
23+
// ==== Request Body
24+
25+
==== Authorization
26+
27+
To use this API, you must have either:
28+
29+
- the `manage_security` cluster privilege (or a greater privilege such as `all`); _or_
30+
- the _"Manage Application Privileges"_ global privilege for the application being referenced
31+
in the request
32+
33+
==== Examples
34+
35+
The following example deletes the `read` application privilege from the
36+
`myapp` application:
37+
38+
[source,js]
39+
--------------------------------------------------
40+
DELETE /_xpack/security/privilege/myapp/read
41+
--------------------------------------------------
42+
// CONSOLE
43+
// TEST[setup:app0102_privileges]
44+
45+
If the role is successfully deleted, the request returns `{"found": true}`.
46+
Otherwise, `found` is set to false.
47+
48+
[source,js]
49+
--------------------------------------------------
50+
{
51+
"myapp": {
52+
"read": {
53+
"found" : true
54+
}
55+
}
56+
}
57+
--------------------------------------------------
58+
// TESTRESPONSE
59+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
[role="xpack"]
2+
[[security-api-get-privileges]]
3+
=== Get application privileges API
4+
5+
Retrieves
6+
{stack-ov}/security-privileges.html#application-privileges[application privileges].
7+
8+
==== Request
9+
10+
`GET /_xpack/security/privilege` +
11+
12+
`GET /_xpack/security/privilege/<application>` +
13+
14+
`GET /_xpack/security/privilege/<application>/<privilege>`
15+
16+
17+
==== Description
18+
19+
To check a user's application privileges, use the
20+
<<security-api-has-privileges,has privileges API>>.
21+
22+
23+
==== Path Parameters
24+
25+
`application`::
26+
(string) The name of the application. Application privileges are always
27+
associated with exactly one application.
28+
If you do not specify this parameter, the API returns information about all
29+
privileges for all applications.
30+
31+
`privilege`::
32+
(string) The name of the privilege. If you do not specify this parameter, the
33+
API returns information about all privileges for the requested application.
34+
35+
//==== Request Body
36+
37+
==== Authorization
38+
39+
To use this API, you must have either:
40+
41+
- the `manage_security` cluster privilege (or a greater privilege such as `all`); _or_
42+
- the _"Manage Application Privileges"_ global privilege for the application being referenced
43+
in the request
44+
45+
==== Examples
46+
47+
The following example retrieves information about the `read` privilege for the
48+
`app01` application:
49+
50+
[source,js]
51+
--------------------------------------------------
52+
GET /_xpack/security/privilege/myapp/read
53+
--------------------------------------------------
54+
// CONSOLE
55+
// TEST[setup:app0102_privileges]
56+
57+
A successful call returns an object keyed by application name and privilege
58+
name. If the privilege is not defined, the request responds with a 404 status.
59+
60+
[source,js]
61+
--------------------------------------------------
62+
{
63+
"myapp": {
64+
"read": {
65+
"application": "myapp",
66+
"name": "read",
67+
"actions": [
68+
"data:read/*",
69+
"action:login"
70+
],
71+
"metadata": {
72+
"description": "Read access to myapp"
73+
}
74+
}
75+
}
76+
}
77+
--------------------------------------------------
78+
// TESTRESPONSE
79+
80+
To retrieve all privileges for an application, omit the privilege name:
81+
82+
[source,js]
83+
--------------------------------------------------
84+
GET /_xpack/security/privilege/myapp/
85+
--------------------------------------------------
86+
// CONSOLE
87+
88+
To retrieve every privilege, omit both the application and privilege names:
89+
90+
[source,js]
91+
--------------------------------------------------
92+
GET /_xpack/security/privilege/
93+
--------------------------------------------------
94+
// CONSOLE

0 commit comments

Comments
 (0)