@@ -56,8 +56,6 @@ then the API key will have a _point in time snapshot of permissions of the
5656authenticated user_. If you supply role descriptors then the resultant permissions
5757would be an intersection of API keys permissions and authenticated user's permissions
5858thereby limiting the access scope for API keys.
59- The structure of role descriptor is the same as the request for create role API.
60- For more details, see <<security-api-put-role, create or update roles API>>.
6159+
6260--
6361NOTE: Due to the way in which this permission intersection is calculated, it is not
@@ -67,6 +65,49 @@ role descriptor with no privileges. The derived API key can be used for
6765authentication; it will not have authority to call {es} APIs.
6866
6967--
68+ +
69+ `applications`::: (list) A list of application privilege entries.
70+ `application` (required):::: (string) The name of the application to which this entry applies
71+ `privileges` (required):::: (list) A list of strings, where each element is the name of an application
72+ privilege or action.
73+ `resources` (required):::: (list) A list resources to which the privileges are applied.
74+
75+ `cluster`::: (list) A list of cluster privileges. These privileges define the
76+ cluster level actions that API keys are able to execute.
77+
78+ `global`::: (object) An object defining global privileges. A global privilege is
79+ a form of cluster privilege that is request-aware. Support for global privileges
80+ is currently limited to the management of application privileges.
81+ This field is optional.
82+
83+ `indices`::: (list) A list of indices permissions entries.
84+ `field_security`:::: (object) The document fields that the API keys have
85+ read access to. For more information, see
86+ <<field-and-document-access-control>>.
87+ `names` (required):::: (list) A list of indices (or index name patterns) to which the
88+ permissions in this entry apply.
89+ `privileges`(required):::: (list) The index level privileges that the API keys
90+ have on the specified indices.
91+ `query`:::: A search query that defines the documents the API keys have
92+ read access to. A document within the specified indices must match this query in
93+ order for it to be accessible by the API keys.
94+
95+ `metadata`::: (object) Optional meta-data. Within the `metadata` object, keys
96+ that begin with `_` are reserved for system usage.
97+
98+ `restriction`::: (object) Optional restriction for when the role descriptor is allowed to be effective. For more information, see
99+ <<role-restriction>>.
100+ `workflows`:::: (list) A list of workflows to which the API key is restricted.
101+ For a full list see <<workflows-restriction>>.
102+ +
103+ --
104+ NOTE: In order to use role restriction, an API key must be created with a *single role descriptor*.
105+ --
106+ +
107+
108+ `run_as`::: (list) A list of users that the API keys can impersonate.
109+ For more information, see
110+ <<run-as-privilege>>.
70111
71112`expiration`::
72113(Optional, string) Expiration time for the API key. By default, API keys never
@@ -92,7 +133,7 @@ POST /_security/api_key
92133 "role_descriptors": { <2>
93134 "role-a": {
94135 "cluster": ["all"],
95- "index ": [
136+ "indices ": [
96137 {
97138 "names": ["index-a*"],
98139 "privileges": ["read"]
@@ -101,7 +142,7 @@ POST /_security/api_key
101142 },
102143 "role-b": {
103144 "cluster": ["all"],
104- "index ": [
145+ "indices ": [
105146 {
106147 "names": ["index-b*"],
107148 "privileges": ["all"]
@@ -170,3 +211,29 @@ echo -n "VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw" | base64 <1>
170211----
171212<1> Use `-n` so that the `echo` command doesn't print the trailing newline
172213character
214+
215+ //tag::create-api-key-with-role-restriction-example[]
216+ The following example creates an API key with a <<role-restriction, restriction>> to the `search_application_query` workflow,
217+ which allows to call only <<search-application-search, Search Application Search API>>:
218+
219+ [source,console]
220+ ----
221+ POST /_security/api_key
222+ {
223+ "name": "my-restricted-api-key",
224+ "role_descriptors": {
225+ "my-restricted-role-descriptor": {
226+ "indices": [
227+ {
228+ "names": ["my-search-app"],
229+ "privileges": ["read"]
230+ }
231+ ],
232+ "restriction": {
233+ "workflows": ["search_application_query"]
234+ }
235+ }
236+ }
237+ }
238+ ----
239+ //end::create-api-key-with-role-restriction-example[]
0 commit comments