Skip to content

Commit 727f1e7

Browse files
[Observability] add .slo-observability.* index privileges to built in editor and viewer roles (#111984)
Today, the `editor` and `viewer` roles do not contain the appropriate index privileges for SLO users. This PR updates the index privileges to include the `.slo-observability.*` indices. --------- Co-authored-by: Slobodan Adamovic <[email protected]>
1 parent 5691848 commit 727f1e7

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,11 @@ private static RoleDescriptor buildViewerRoleDescriptor() {
868868
.indices("/~(([.]|ilm-history-).*)/")
869869
.privileges("read", "view_index_metadata")
870870
.build(),
871+
// Observability
872+
RoleDescriptor.IndicesPrivileges.builder()
873+
.indices(".slo-observability.*")
874+
.privileges("read", "view_index_metadata")
875+
.build(),
871876
// Security
872877
RoleDescriptor.IndicesPrivileges.builder()
873878
.indices(ReservedRolesStore.ALERTS_LEGACY_INDEX, ReservedRolesStore.LISTS_INDEX, ReservedRolesStore.LISTS_ITEMS_INDEX)
@@ -915,6 +920,10 @@ private static RoleDescriptor buildEditorRoleDescriptor() {
915920
.indices("observability-annotations")
916921
.privileges("read", "view_index_metadata", "write")
917922
.build(),
923+
RoleDescriptor.IndicesPrivileges.builder()
924+
.indices(".slo-observability.*")
925+
.privileges("read", "view_index_metadata", "write", "manage")
926+
.build(),
918927
// Security
919928
RoleDescriptor.IndicesPrivileges.builder()
920929
.indices(ReservedRolesStore.ALERTS_LEGACY_INDEX, ReservedRolesStore.LISTS_INDEX, ReservedRolesStore.LISTS_ITEMS_INDEX)

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.action.admin.indices.get.GetIndexAction;
2929
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsAction;
3030
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsAction;
31+
import org.elasticsearch.action.admin.indices.mapping.put.TransportAutoPutMappingAction;
3132
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
3233
import org.elasticsearch.action.admin.indices.recovery.RecoveryAction;
3334
import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction;
@@ -3662,6 +3663,9 @@ public void testPredefinedViewerRole() {
36623663
assertOnlyReadAllowed(role, ".profiling-" + randomIntBetween(0, 5));
36633664
assertOnlyReadAllowed(role, randomAlphaOfLength(5));
36643665

3666+
assertOnlyReadAllowed(role, ".slo-observability." + randomIntBetween(0, 5));
3667+
assertViewIndexMetadata(role, ".slo-observability." + randomIntBetween(0, 5));
3668+
36653669
assertNoAccessAllowed(role, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES);
36663670
assertNoAccessAllowed(role, "." + randomAlphaOfLengthBetween(6, 10));
36673671
assertNoAccessAllowed(role, "ilm-history-" + randomIntBetween(0, 5));
@@ -3740,6 +3744,9 @@ public void testPredefinedEditorRole() {
37403744
assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(role, ".preview.alerts-" + randomIntBetween(0, 5));
37413745
assertReadWriteDocsAndMaintenanceButNotDeleteIndexAllowed(role, ".internal.preview.alerts-" + randomIntBetween(0, 5));
37423746

3747+
assertViewIndexMetadata(role, ".slo-observability." + randomIntBetween(0, 5));
3748+
assertReadWriteAndManage(role, ".slo-observability." + randomIntBetween(0, 5));
3749+
37433750
assertNoAccessAllowed(role, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES);
37443751
assertNoAccessAllowed(role, "." + randomAlphaOfLengthBetween(6, 10));
37453752
assertNoAccessAllowed(role, "ilm-history-" + randomIntBetween(0, 5));
@@ -3865,6 +3872,41 @@ private void assertReadWriteDocsButNotDeleteIndexAllowed(Role role, String index
38653872
role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)),
38663873
is(false)
38673874
);
3875+
3876+
assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true));
3877+
assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true));
3878+
assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true));
3879+
assertThat(role.indices().allowedIndicesMatcher(TransportUpdateAction.NAME).test(mockIndexAbstraction(index)), is(true));
3880+
assertThat(role.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(mockIndexAbstraction(index)), is(true));
3881+
assertThat(role.indices().allowedIndicesMatcher(TransportBulkAction.NAME).test(mockIndexAbstraction(index)), is(true));
3882+
}
3883+
3884+
private void assertReadWriteAndManage(Role role, String index) {
3885+
assertThat(
3886+
role.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(mockIndexAbstraction(index)),
3887+
is(true)
3888+
);
3889+
assertThat(
3890+
role.indices().allowedIndicesMatcher(TransportFieldCapabilitiesAction.NAME + "*").test(mockIndexAbstraction(index)),
3891+
is(true)
3892+
);
3893+
assertThat(
3894+
role.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(mockIndexAbstraction(index)),
3895+
is(true)
3896+
);
3897+
assertThat(
3898+
role.indices().allowedIndicesMatcher(TransportUpdateSettingsAction.TYPE.name()).test(mockIndexAbstraction(index)),
3899+
is(true)
3900+
);
3901+
assertThat(role.indices().allowedIndicesMatcher(GetRollupIndexCapsAction.NAME + "*").test(mockIndexAbstraction(index)), is(true));
3902+
assertThat(role.indices().allowedIndicesMatcher("indices:admin/*").test(mockIndexAbstraction(index)), is(true));
3903+
assertThat(role.indices().allowedIndicesMatcher("indices:monitor/*").test(mockIndexAbstraction(index)), is(true));
3904+
assertThat(
3905+
role.indices().allowedIndicesMatcher(TransportAutoPutMappingAction.TYPE.name()).test(mockIndexAbstraction(index)),
3906+
is(true)
3907+
);
3908+
assertThat(role.indices().allowedIndicesMatcher(AutoCreateAction.NAME).test(mockIndexAbstraction(index)), is(true));
3909+
38683910
assertThat(role.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true));
38693911
assertThat(role.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(mockIndexAbstraction(index)), is(true));
38703912
assertThat(role.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(mockIndexAbstraction(index)), is(true));

0 commit comments

Comments
 (0)