Skip to content

Commit 090a395

Browse files
committed
Add access object
1 parent 6297810 commit 090a395

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RemoteIndicesPrivileges, ReplicationAccess } from './Privileges'
21+
22+
export class Access {
23+
/**
24+
* A list of indices permission entries for cross-cluster replication.
25+
*/
26+
replication?: ReplicationAccess[]
27+
/**
28+
* A list of indices permission entries for cross-cluster search.
29+
*/
30+
search?: RemoteIndicesPrivileges[]
31+
}

specification/security/_types/Privileges.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,10 @@ export class ApplicationGlobalUserPrivileges {
376376
export class ManageUserPrivileges {
377377
applications: string[]
378378
}
379+
380+
export class ReplicationAccess {
381+
/**
382+
* A list of indices (or index name patterns) to which the permissions in this entry apply.
383+
*/
384+
names: IndexName[]
385+
}

specification/security/create_cross_cluster_api_key/CreateCrossClusterApiKeyRequest.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
*/
1919

2020
import { RequestBase } from '@_types/Base'
21+
import { Dictionary } from '@spec_utils/Dictionary'
2122
import { Metadata, Name } from '@_types/common'
2223
import { Duration } from '@_types/Time'
24+
import { Access } from '@security/_types/Access'
2325

2426
/**
2527
* Create a cross-cluster API key.
@@ -30,6 +32,8 @@ import { Duration } from '@_types/Time'
3032
* IMPORTANT: To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error.
3133
*
3234
* Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled.
35+
*
36+
* NOTE: Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the `access` property.
3337
*
3438
* A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds.
3539
*
@@ -44,6 +48,15 @@ import { Duration } from '@_types/Time'
4448
*/
4549
export interface Request extends RequestBase {
4650
body: {
51+
/**
52+
* The access to be granted to this API key.
53+
* The access is composed of permissions for cross-cluster search and cross-cluster replication.
54+
* At least one of them must be specified.
55+
*
56+
* NOTE: No explicit privileges should be specified for either search or replication access.
57+
* The creation process automatically converts the access specification to a role descriptor which has relevant privileges assigned accordingly.
58+
*/
59+
access: Access
4760
/**
4861
* Expiration time for the API key.
4962
* By default, API keys never expire.

specification/security/update_cross_cluster_api_key/UpdateCrossClusterApiKeyRequest.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import { RequestBase } from '@_types/Base'
2121
import { Id, Metadata } from '@_types/common'
2222
import { Duration } from '@_types/Time'
23+
import { Access } from '@security/_types/Access'
24+
import { Dictionary } from '@spec_utils/Dictionary'
2325

2426
/**
2527
* Update a cross-cluster API key.
@@ -37,6 +39,13 @@ export interface Request extends RequestBase {
3739
id: Id
3840
}
3941
body: {
42+
/**
43+
* The access to be granted to this API key.
44+
* The access is composed of permissions for cross cluster search and cross cluster replication.
45+
* At least one of them must be specified.
46+
* When specified, the new access assignment fully replaces the previously assigned access.
47+
*/
48+
access: Access
4049
/**
4150
* Expiration time for the API key.
4251
* By default, API keys never expire. This property can be omitted to leave the value unchanged.

0 commit comments

Comments
 (0)