Skip to content

Commit 4051f0f

Browse files
committed
Expanding beats_system role so Beats can directly index monitoring data to monitoring cluster
1 parent 5283c49 commit 4051f0f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
133133
},
134134
null, MetadataUtils.DEFAULT_RESERVED_METADATA))
135135
.put(UsernamesField.BEATS_ROLE, new RoleDescriptor(UsernamesField.BEATS_ROLE,
136-
new String[] { "monitor", MonitoringBulkAction.NAME}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
136+
new String[] { "monitor", MonitoringBulkAction.NAME},
137+
new RoleDescriptor.IndicesPrivileges[]{
138+
RoleDescriptor.IndicesPrivileges.builder().indices(".monitoring-beats-*").privileges("create_index", "write").build()
139+
},
140+
null, MetadataUtils.DEFAULT_RESERVED_METADATA))
137141
.put(UsernamesField.APM_ROLE, new RoleDescriptor(UsernamesField.APM_ROLE,
138142
new String[] { "monitor", MonitoringBulkAction.NAME}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
139143
.put("apm_user", new RoleDescriptor("apm_user",

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,17 @@ public void testBeatsSystemRole() {
849849

850850
assertThat(beatsSystemRole.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
851851

852+
853+
final String index = ".monitoring-beats-" + randomIntBetween(0, 5);;
854+
logger.info("index name [{}]", index);
852855
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test("foo"), is(false));
853856
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(".reporting"), is(false));
854857
assertThat(beatsSystemRole.indices().allowedIndicesMatcher("indices:foo").test(randomAlphaOfLengthBetween(8, 24)),
855858
is(false));
859+
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(true));
860+
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(true));
861+
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(true));
862+
assertThat(beatsSystemRole.indices().allowedIndicesMatcher(BulkAction.NAME).test(index), is(true));
856863

857864
assertNoAccessAllowed(beatsSystemRole, RestrictedIndicesNames.RESTRICTED_NAMES);
858865
}

0 commit comments

Comments
 (0)