Skip to content

Commit 610f39b

Browse files
ywangdemilioalvap
andauthored
[Synthetics] Add synthetics-* read to fleet-server (#91391) (#91572)
Add read synthetics-* privilege for elastic/fleet-server service account. related: elastic/beats#33299 Co-authored-by: Emilio Alvarez Piñeiro <[email protected]>
1 parent 4cd76f2 commit 610f39b

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

x-pack/docs/en/rest-api/security/get-service-accounts.asciidoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ GET /_security/service/elastic/fleet-server
7373
"logs-*",
7474
"metrics-*",
7575
"traces-*",
76-
"synthetics-*",
7776
".logs-endpoint.diagnostic.collection-*",
7877
".logs-endpoint.action.responses-*"
7978
],
@@ -108,6 +107,18 @@ GET /_security/service/elastic/fleet-server
108107
"maintenance"
109108
],
110109
"allow_restricted_indices": true
110+
},
111+
{
112+
"names": [
113+
"synthetics-*"
114+
],
115+
"privileges": [
116+
"read",
117+
"write",
118+
"create_index",
119+
"auto_configure"
120+
],
121+
"allow_restricted_indices": false
111122
}
112123
],
113124
"applications": [

x-pack/plugin/security/qa/service-account/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/service/ServiceAccountIT.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public class ServiceAccountIT extends ESRestTestCase {
9090
"logs-*",
9191
"metrics-*",
9292
"traces-*",
93-
"synthetics-*",
9493
".logs-endpoint.diagnostic.collection-*",
9594
".logs-endpoint.action.responses-*"
9695
],
@@ -125,6 +124,18 @@ public class ServiceAccountIT extends ESRestTestCase {
125124
"maintenance"
126125
],
127126
"allow_restricted_indices": true
127+
},
128+
{
129+
"names": [
130+
"synthetics-*"
131+
],
132+
"privileges": [
133+
"read",
134+
"write",
135+
"create_index",
136+
"auto_configure"
137+
],
138+
"allow_restricted_indices": false
128139
}
129140
],
130141
"applications": [ {

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccounts.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ final class ElasticServiceAccounts {
6868
"logs-*",
6969
"metrics-*",
7070
"traces-*",
71-
"synthetics-*",
7271
".logs-endpoint.diagnostic.collection-*",
7372
".logs-endpoint.action.responses-*"
7473
)
@@ -88,6 +87,12 @@ final class ElasticServiceAccounts {
8887
// Fleet Server needs "maintenance" privilege to be able to perform operations with "refresh"
8988
.privileges("read", "write", "monitor", "create_index", "auto_configure", "maintenance")
9089
.allowRestrictedIndices(true)
90+
.build(),
91+
RoleDescriptor.IndicesPrivileges.builder()
92+
.indices("synthetics-*")
93+
// Fleet Server needs "read" privilege to be able to retrieve multi-agent docs
94+
.privileges("read", "write", "create_index", "auto_configure")
95+
.allowRestrictedIndices(false)
9196
.build() },
9297
new RoleDescriptor.ApplicationResourcePrivileges[] {
9398
RoleDescriptor.ApplicationResourcePrivileges.builder()

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/service/ElasticServiceAccountsTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public void testElasticFleetServerPrivileges() {
177177
"logs-" + randomAlphaOfLengthBetween(1, 20),
178178
"metrics-" + randomAlphaOfLengthBetween(1, 20),
179179
"traces-" + randomAlphaOfLengthBetween(1, 20),
180-
"synthetics-" + randomAlphaOfLengthBetween(1, 20),
181180
".logs-endpoint.diagnostic.collection-" + randomAlphaOfLengthBetween(1, 20),
182181
".logs-endpoint.action.responses-" + randomAlphaOfLengthBetween(1, 20)
183182
).stream().map(this::mockIndexAbstraction).forEach(index -> {
@@ -195,6 +194,21 @@ public void testElasticFleetServerPrivileges() {
195194
assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
196195
});
197196

197+
List.of("synthetics-" + randomAlphaOfLengthBetween(1, 20)).stream().map(this::mockIndexAbstraction).forEach(index -> {
198+
assertThat(role.indices().allowedIndicesMatcher(AutoPutMappingAction.NAME).test(index), is(true));
199+
assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(index), is(true));
200+
assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
201+
assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
202+
assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
203+
assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true));
204+
assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false));
205+
assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
206+
assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(index), is(true));
207+
assertThat(role.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
208+
assertThat(role.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
209+
assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
210+
});
211+
198212
List.of(
199213
".fleet-" + randomAlphaOfLengthBetween(1, 20),
200214
".fleet-action" + randomAlphaOfLengthBetween(1, 20),

0 commit comments

Comments
 (0)