diff --git a/build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle b/build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle index a3c7300cea951..7f9ea3d8eb28a 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.run-ccs.gradle @@ -14,6 +14,8 @@ boolean basicSecurityMode = Boolean.valueOf(providers.systemProperty('basicSecur def fulfillingCluster = testClusters.register('fulfilling-cluster') { testDistribution = providers.systemProperty('run.distribution').orElse('default').get() + + version = '8.14.0' setting 'xpack.security.enabled', 'true' setting 'xpack.watcher.enabled', 'false' setting 'xpack.ml.enabled', 'false' diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java index 235264c8889de..3e3b1178b372c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java @@ -1417,32 +1417,14 @@ private static BytesReference convertRoleDescriptorsMapToBytes(Map roleDescriptorsMap = convertRoleDescriptorsBytesToMap(roleDescriptorsBytes); - final AtomicBoolean removedAtLeastOne = new AtomicBoolean(false); - roleDescriptorsMap.forEach((key, value) -> { - if (value instanceof Map) { - @SuppressWarnings("unchecked") - Map roleDescriptor = (Map) value; - boolean removed = roleDescriptor.remove(RoleDescriptor.Fields.REMOTE_CLUSTER.getPreferredName()) != null; - if (removed) { - removedAtLeastOne.set(true); - } - } - }); - - if (removedAtLeastOne.get()) { - return convertRoleDescriptorsMapToBytes(roleDescriptorsMap); - } else { - // No need to serialize if we did not remove anything. - return roleDescriptorsBytes; - } + return maybeRemoveTopLevelFromRoleDescriptors(roleDescriptorsBytes, RoleDescriptor.Fields.REMOTE_CLUSTER.getPreferredName()); } static BytesReference maybeRemoveRemoteIndicesFromRoleDescriptors(BytesReference roleDescriptorsBytes) { + return maybeRemoveTopLevelFromRoleDescriptors(roleDescriptorsBytes, RoleDescriptor.Fields.REMOTE_INDICES.getPreferredName()); + } + + static BytesReference maybeRemoveTopLevelFromRoleDescriptors(BytesReference roleDescriptorsBytes, String topLevelField) { if (roleDescriptorsBytes == null || roleDescriptorsBytes.length() == 0) { return roleDescriptorsBytes; } @@ -1453,7 +1435,7 @@ static BytesReference maybeRemoveRemoteIndicesFromRoleDescriptors(BytesReference if (value instanceof Map) { @SuppressWarnings("unchecked") Map roleDescriptor = (Map) value; - boolean removed = roleDescriptor.remove(RoleDescriptor.Fields.REMOTE_INDICES.getPreferredName()) != null; + boolean removed = roleDescriptor.remove(topLevelField) != null; if (removed) { removedAtLeastOne.set(true); }