Skip to content

Commit

Permalink
Introduce reserved_ml_apm_user kibana privilege (#59854)
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego authored Jul 22, 2020
1 parent 83743ee commit fc94423
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
.privileges("read", "view_index_metadata").build(),
RoleDescriptor.IndicesPrivileges.builder().indices("observability-annotations")
.privileges("read", "view_index_metadata").build()
}, null, MetadataUtils.DEFAULT_RESERVED_METADATA))
}, new RoleDescriptor.ApplicationResourcePrivileges[] {
RoleDescriptor.ApplicationResourcePrivileges.builder()
.application("kibana-*").resources("*").privileges("reserved_ml_apm_user").build()
}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA, null))
.put("machine_learning_user", new RoleDescriptor("machine_learning_user", new String[] { "monitor_ml" },
new RoleDescriptor.IndicesPrivileges[] {
RoleDescriptor.IndicesPrivileges.builder().indices(".ml-anomalies*", ".ml-notifications*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,18 @@ public void testAPMUserRole() {
assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT);

assertOnlyReadAllowed(role, "observability-annotations");

final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
assertThat(role.application().grants(
new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-foo", "foo"), "*"), is(false));
assertThat(role.application().grants(
new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-reserved_ml_apm_user", "reserved_ml_apm_user"), "*"), is(true));

final String otherApplication = "logstash-" + randomAlphaOfLengthBetween(8, 24);
assertThat(role.application().grants(
new ApplicationPrivilege(otherApplication, "app-foo", "foo"), "*"), is(false));
assertThat(role.application().grants(
new ApplicationPrivilege(otherApplication, "app-reserved_ml_apm_user", "reserved_ml_apm_user"), "*"), is(false));
}

public void testMachineLearningAdminRole() {
Expand Down

0 comments on commit fc94423

Please sign in to comment.