Skip to content

Commit def2f27

Browse files
ywangdtvernum
andauthored
Phase 1 support for operator privileges (#65256)
In some Elastic Stack environments, there is a distinction between the operator of the cluster infrastructure and the administrator of the cluster. This distinction cannot be supported currently because the "administrator" often has the superuser role which grants each and every privilege of the cluster. This PR adds a new feature to protect a fixed set of APIs from the "administrator" even when it is a highly privileged user such as superuser. It enhances the Elasticsearch security model to have an additional layer of restriction in addition to the RBAC. Co-authored-by: Tim Vernum <[email protected]>
1 parent 7518b1c commit def2f27

File tree

31 files changed

+1913
-41
lines changed

31 files changed

+1913
-41
lines changed

docs/reference/rest-api/info.asciidoc

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ Example response:
103103
"available" : true,
104104
"enabled" : true
105105
},
106+
"operator_privileges": {
107+
"available": true,
108+
"enabled": false
109+
},
106110
"rollup": {
107111
"available": true,
108112
"enabled": true

x-pack/plugin/core/src/main/java/org/elasticsearch/license/XPackLicenseState.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public enum Feature {
100100

101101
ANALYTICS(OperationMode.MISSING, true),
102102

103-
SEARCHABLE_SNAPSHOTS(OperationMode.ENTERPRISE, true);
103+
SEARCHABLE_SNAPSHOTS(OperationMode.ENTERPRISE, true),
104+
105+
OPERATOR_PRIVILEGES(OperationMode.ENTERPRISE, true);
104106

105107
final OperationMode minimumOperationMode;
106108
final boolean needsActive;

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackField.java

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public final class XPackField {
6767
public static final String DATA_TIERS = "data_tiers";
6868
/** Name constant for the aggregate_metric plugin. */
6969
public static final String AGGREGATE_METRIC = "aggregate_metric";
70+
/** Name constant for the operator privileges feature. */
71+
public static final String OPERATOR_PRIVILEGES = "operator_privileges";
7072

7173
private XPackField() {}
7274

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ public class XPackInfoFeatureAction extends ActionType<XPackInfoFeatureResponse>
4747
public static final XPackInfoFeatureAction DATA_STREAMS = new XPackInfoFeatureAction(XPackField.DATA_STREAMS);
4848
public static final XPackInfoFeatureAction DATA_TIERS = new XPackInfoFeatureAction(XPackField.DATA_TIERS);
4949
public static final XPackInfoFeatureAction AGGREGATE_METRIC = new XPackInfoFeatureAction(XPackField.AGGREGATE_METRIC);
50+
public static final XPackInfoFeatureAction OPERATOR_PRIVILEGES = new XPackInfoFeatureAction(XPackField.OPERATOR_PRIVILEGES);
5051

5152
public static final List<XPackInfoFeatureAction> ALL;
5253
static {
5354
final List<XPackInfoFeatureAction> actions = new ArrayList<>();
5455
actions.addAll(Arrays.asList(
5556
SECURITY, MONITORING, WATCHER, GRAPH, MACHINE_LEARNING, LOGSTASH, EQL, SQL, ROLLUP, INDEX_LIFECYCLE, SNAPSHOT_LIFECYCLE, CCR,
5657
TRANSFORM, VECTORS, VOTING_ONLY, FROZEN_INDICES, SPATIAL, ANALYTICS, ENRICH, DATA_STREAMS, SEARCHABLE_SNAPSHOTS, DATA_TIERS,
57-
AGGREGATE_METRIC
58+
AGGREGATE_METRIC, OPERATOR_PRIVILEGES
5859
));
5960
ALL = Collections.unmodifiableList(actions);
6061
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/AuthenticationField.java

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public final class AuthenticationField {
1010
public static final String AUTHENTICATION_KEY = "_xpack_security_authentication";
1111
public static final String API_KEY_ROLE_DESCRIPTORS_KEY = "_security_api_key_role_descriptors";
1212
public static final String API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY = "_security_api_key_limited_by_role_descriptors";
13+
public static final String PRIVILEGE_CATEGORY_KEY = "_security_privilege_category";
14+
public static final String PRIVILEGE_CATEGORY_VALUE_OPERATOR = "operator";
1315

1416
private AuthenticationField() {}
1517
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'elasticsearch.esplugin'
2+
apply plugin: 'elasticsearch.java-rest-test'
3+
4+
esplugin {
5+
name 'operator-privileges-test'
6+
description 'An test plugin for testing hard to get internals'
7+
classname 'org.elasticsearch.xpack.security.operator.OperatorPrivilegesTestPlugin'
8+
}
9+
10+
dependencies {
11+
compileOnly project(':x-pack:plugin:core')
12+
javaRestTestImplementation project(':x-pack:plugin:core')
13+
javaRestTestImplementation project(':client:rest-high-level')
14+
javaRestTestImplementation project(':x-pack:plugin:security')
15+
// let the javaRestTest see the classpath of main
16+
javaRestTestImplementation project.sourceSets.main.runtimeClasspath
17+
}
18+
19+
testClusters.all {
20+
testDistribution = 'DEFAULT'
21+
numberOfNodes = 3
22+
23+
extraConfigFile 'operator_users.yml', file('src/javaRestTest/resources/operator_users.yml')
24+
extraConfigFile 'roles.yml', file('src/javaRestTest/resources/roles.yml')
25+
26+
setting 'xpack.license.self_generated.type', 'trial'
27+
setting 'xpack.security.enabled', 'true'
28+
setting 'xpack.security.http.ssl.enabled', 'false'
29+
setting 'xpack.security.operator_privileges.enabled', "true"
30+
31+
user username: "test_admin", password: 'x-pack-test-password', role: "superuser"
32+
user username: "test_operator", password: 'x-pack-test-password', role: "limited_operator"
33+
}

0 commit comments

Comments
 (0)