|
@@ -186,6 +186,8 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
assertThat(ReservedRolesStore.isReserved("machine_learning_admin"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("data_frame_transforms_user"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("data_frame_transforms_admin"), is(true));
|
|
|
+ assertThat(ReservedRolesStore.isReserved("transform_user"), is(true));
|
|
|
+ assertThat(ReservedRolesStore.isReserved("transform_admin"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("watcher_user"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("watcher_admin"), is(true));
|
|
|
assertThat(ReservedRolesStore.isReserved("kibana_dashboard_only_user"), is(true));
|
|
@@ -1121,82 +1123,108 @@ public class ReservedRolesStoreTests extends ESTestCase {
|
|
|
new ApplicationPrivilege(otherApplication, "app-reserved_ml", "reserved_ml"), "*"), is(false));
|
|
|
}
|
|
|
|
|
|
- public void testDataFrameTransformsAdminRole() {
|
|
|
+ public void testTransformAdminRole() {
|
|
|
final TransportRequest request = mock(TransportRequest.class);
|
|
|
final Authentication authentication = mock(Authentication.class);
|
|
|
|
|
|
- RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor("data_frame_transforms_admin");
|
|
|
- assertNotNull(roleDescriptor);
|
|
|
- assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
-
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
- assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(PreviewTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(PutTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(StartTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(StopTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
-
|
|
|
- assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
|
|
|
-
|
|
|
- assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX);
|
|
|
- assertNoAccessAllowed(role, "foo");
|
|
|
- assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME); // internal use only
|
|
|
-
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
-
|
|
|
- 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", "reserved_ml"), "*"), 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", "reserved_ml"), "*"), is(false));
|
|
|
+ RoleDescriptor[] roleDescriptors = {
|
|
|
+ new ReservedRolesStore().roleDescriptor("data_frame_transforms_admin"),
|
|
|
+ new ReservedRolesStore().roleDescriptor("transform_admin")
|
|
|
+ };
|
|
|
+
|
|
|
+ for (RoleDescriptor roleDescriptor : roleDescriptors) {
|
|
|
+ assertNotNull(roleDescriptor);
|
|
|
+ assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
+
|
|
|
+ Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(PreviewTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(PutTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(StartTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(StopTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
+
|
|
|
+ assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
|
|
|
+
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_READ_ALIAS);
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_PATTERN);
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_PATTERN_DEPRECATED);
|
|
|
+ assertNoAccessAllowed(role, "foo");
|
|
|
+ assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME); // internal use only
|
|
|
+
|
|
|
+ assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
+
|
|
|
+ final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-foo", "foo"), "*"), is(false));
|
|
|
+
|
|
|
+ if (roleDescriptor.getName().equals("data_frame_transforms_admin")) {
|
|
|
+ assertThat(role.application()
|
|
|
+ .grants(new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-reserved_ml", "reserved_ml"), "*"), is(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ final String otherApplication = "logstash-" + randomAlphaOfLengthBetween(8, 24);
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(otherApplication, "app-foo", "foo"), "*"), is(false));
|
|
|
+ if (roleDescriptor.getName().equals("data_frame_transforms_admin")) {
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(otherApplication, "app-reserved_ml", "reserved_ml"), "*"), is(false));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testDataFrameTransformsUserRole() {
|
|
|
final TransportRequest request = mock(TransportRequest.class);
|
|
|
final Authentication authentication = mock(Authentication.class);
|
|
|
|
|
|
- RoleDescriptor roleDescriptor = new ReservedRolesStore().roleDescriptor("data_frame_transforms_user");
|
|
|
- assertNotNull(roleDescriptor);
|
|
|
- assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
-
|
|
|
- Role role = Role.builder(roleDescriptor, null).build();
|
|
|
- assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(false));
|
|
|
- assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
- assertThat(role.cluster().check(PreviewTransformAction.NAME, request, authentication), is(false));
|
|
|
- assertThat(role.cluster().check(PutTransformAction.NAME, request, authentication), is(false));
|
|
|
- assertThat(role.cluster().check(StartTransformAction.NAME, request, authentication), is(false));
|
|
|
- assertThat(role.cluster().check(StopTransformAction.NAME, request, authentication), is(false));
|
|
|
- assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
-
|
|
|
- assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
|
|
|
-
|
|
|
- assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX);
|
|
|
- assertNoAccessAllowed(role, "foo");
|
|
|
- assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME);
|
|
|
-
|
|
|
- assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
-
|
|
|
- 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", "reserved_ml"), "*"), 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", "reserved_ml"), "*"), is(false));
|
|
|
+ RoleDescriptor[] roleDescriptors = {
|
|
|
+ new ReservedRolesStore().roleDescriptor("data_frame_transforms_user"),
|
|
|
+ new ReservedRolesStore().roleDescriptor("transform_user")
|
|
|
+ };
|
|
|
+
|
|
|
+ for (RoleDescriptor roleDescriptor : roleDescriptors) {
|
|
|
+ assertNotNull(roleDescriptor);
|
|
|
+ assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
|
|
|
+
|
|
|
+ Role role = Role.builder(roleDescriptor, null).build();
|
|
|
+ assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(false));
|
|
|
+ assertThat(role.cluster().check(GetTransformAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(GetTransformStatsAction.NAME, request, authentication), is(true));
|
|
|
+ assertThat(role.cluster().check(PreviewTransformAction.NAME, request, authentication), is(false));
|
|
|
+ assertThat(role.cluster().check(PutTransformAction.NAME, request, authentication), is(false));
|
|
|
+ assertThat(role.cluster().check(StartTransformAction.NAME, request, authentication), is(false));
|
|
|
+ assertThat(role.cluster().check(StopTransformAction.NAME, request, authentication), is(false));
|
|
|
+ assertThat(role.cluster().check(DelegatePkiAuthenticationAction.NAME, request, authentication), is(false));
|
|
|
+
|
|
|
+ assertThat(role.runAs().check(randomAlphaOfLengthBetween(1, 30)), is(false));
|
|
|
+
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_READ_ALIAS);
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_PATTERN);
|
|
|
+ assertOnlyReadAllowed(role, TransformInternalIndexConstants.AUDIT_INDEX_PATTERN_DEPRECATED);
|
|
|
+ assertNoAccessAllowed(role, "foo");
|
|
|
+ assertNoAccessAllowed(role, TransformInternalIndexConstants.LATEST_INDEX_NAME);
|
|
|
+
|
|
|
+ assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
|
|
|
+
|
|
|
+ final String kibanaApplicationWithRandomIndex = "kibana-" + randomFrom(randomAlphaOfLengthBetween(8, 24), ".kibana");
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-foo", "foo"), "*"), is(false));
|
|
|
+
|
|
|
+ if (roleDescriptor.getName().equals("data_frame_transforms_user")) {
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(kibanaApplicationWithRandomIndex, "app-reserved_ml", "reserved_ml"), "*"), is(true));
|
|
|
+ }
|
|
|
+
|
|
|
+ final String otherApplication = "logstash-" + randomAlphaOfLengthBetween(8, 24);
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(otherApplication, "app-foo", "foo"), "*"), is(false));
|
|
|
+ if (roleDescriptor.getName().equals("data_frame_transforms_user")) {
|
|
|
+ assertThat(role.application().grants(
|
|
|
+ new ApplicationPrivilege(otherApplication, "app-reserved_ml", "reserved_ml"), "*"), is(false));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void testWatcherAdminRole() {
|