Skip to content

Commit 21b0203

Browse files
committed
Extend fleet-server service account privileges
Allow elastic/fleet-server service account to additionally read, monitor, and refresh traces-apm.sampled-* data streams. These data streams do not contain any sensitive information. Fleet-server itself does not need to perform these actions, but it creates API Keys for APM Server, which does need to.
1 parent 7018e9e commit 21b0203

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ GET /_security/service/elastic/fleet-server
8484
],
8585
"allow_restricted_indices": false
8686
},
87+
{
88+
"names" : [
89+
"traces-apm.sampled-*"
90+
],
91+
"privileges" : [
92+
"read",
93+
"write",
94+
"monitor",
95+
"create_index",
96+
"auto_configure",
97+
"maintenance"
98+
],
99+
"allow_restricted_indices": false
100+
},
87101
{
88102
"names": [
89103
".fleet-*"

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ public class ServiceAccountIT extends ESRestTestCase {
101101
],
102102
"allow_restricted_indices": false
103103
},
104+
{
105+
"names": [
106+
"traces-apm.sampled-*"
107+
],
108+
"privileges": [
109+
"read",
110+
"write",
111+
"monitor",
112+
"create_index",
113+
"auto_configure",
114+
"maintenance"
115+
],
116+
"allow_restricted_indices": false
117+
},
104118
{
105119
"names": [
106120
".fleet-*"

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ final class ElasticServiceAccounts {
3939
)
4040
.privileges("write", "create_index", "auto_configure")
4141
.build(),
42+
RoleDescriptor.IndicesPrivileges.builder()
43+
// APM Server (and hence Fleet Server, which issues its API Keys) needs additional privileges
44+
// for the non-sensitive "sampled traces" data stream:
45+
// - "maintenance" privilege to refresh indices
46+
// - "monitor" privilege to be able to query index stats for the global checkpoint
47+
// - "read" privilege to search the documents
48+
.indices("traces-apm.sampled-*")
49+
.privileges("read", "write", "monitor", "create_index", "auto_configure", "maintenance")
50+
.build(),
4251
RoleDescriptor.IndicesPrivileges.builder()
4352
.indices(".fleet-*")
4453
// Fleet Server needs "maintenance" privilege to be able to perform operations with "refresh"

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,19 @@ public void testElasticFleetServerPrivileges() {
206206
assertThat(role.indices().allowedIndicesMatcher("indices:foo").test(dotFleetIndex), is(false));
207207
});
208208

209+
final IndexAbstraction apmSampledTracesIndex = mockIndexAbstraction("traces-apm.sampled-" + randomAlphaOfLengthBetween(1, 20));
210+
assertThat(role.indices().allowedIndicesMatcher(DeleteAction.NAME).test(apmSampledTracesIndex), is(true));
211+
assertThat(role.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(apmSampledTracesIndex), is(true));
212+
assertThat(role.indices().allowedIndicesMatcher(IndexAction.NAME).test(apmSampledTracesIndex), is(true));
213+
assertThat(role.indices().allowedIndicesMatcher(BulkAction.NAME).test(apmSampledTracesIndex), is(true));
214+
assertThat(role.indices().allowedIndicesMatcher(GetAction.NAME).test(apmSampledTracesIndex), is(true));
215+
assertThat(role.indices().allowedIndicesMatcher(MultiGetAction.NAME).test(apmSampledTracesIndex), is(true));
216+
assertThat(role.indices().allowedIndicesMatcher(SearchAction.NAME).test(apmSampledTracesIndex), is(true));
217+
assertThat(role.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(apmSampledTracesIndex), is(true));
218+
assertThat(role.indices().allowedIndicesMatcher(IndicesStatsAction.NAME).test(apmSampledTracesIndex), is(true));
219+
assertThat(role.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(apmSampledTracesIndex), is(false));
220+
assertThat(role.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(apmSampledTracesIndex), is(false));
221+
209222
final String kibanaApplication = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
210223
final String privilegeName = randomAlphaOfLengthBetween(3, 16);
211224
assertThat(

0 commit comments

Comments
 (0)