|
@@ -9,7 +9,6 @@ package org.elasticsearch.xpack.core.security.authc;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.elasticsearch.TransportVersion;
|
|
|
-import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.bytes.BytesReference;
|
|
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
@@ -56,6 +55,7 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
+import static org.elasticsearch.transport.RemoteClusterPortSettings.TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY;
|
|
|
import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg;
|
|
|
import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg;
|
|
|
import static org.elasticsearch.xpack.core.security.authc.Authentication.RealmRef.newAnonymousRealmRef;
|
|
@@ -107,12 +107,9 @@ public final class Authentication implements ToXContentObject {
|
|
|
private static final Logger logger = LogManager.getLogger(Authentication.class);
|
|
|
private static final TransportVersion VERSION_AUTHENTICATION_TYPE = TransportVersion.fromId(6_07_00_99);
|
|
|
|
|
|
- public static final TransportVersion VERSION_CROSS_CLUSTER_ACCESS_REALM = TransportVersion.V_8_8_0;
|
|
|
public static final TransportVersion VERSION_API_KEY_ROLES_AS_BYTES = TransportVersion.V_7_9_0;
|
|
|
public static final TransportVersion VERSION_REALM_DOMAINS = TransportVersion.V_8_2_0;
|
|
|
public static final TransportVersion VERSION_METADATA_BEYOND_GENERIC_MAP = TransportVersion.V_8_8_0;
|
|
|
- public static final Version VERSION_API_KEYS_WITH_REMOTE_INDICES = Version.V_8_8_0;
|
|
|
- public static final TransportVersion TRANSPORT_VERSION_API_KEYS_WITH_REMOTE_INDICES = TransportVersion.V_8_8_0;
|
|
|
private final AuthenticationType type;
|
|
|
private final Subject authenticatingSubject;
|
|
|
private final Subject effectiveSubject;
|
|
@@ -227,10 +224,10 @@ public final class Authentication implements ToXContentObject {
|
|
|
|
|
|
// cross cluster access introduced a new synthetic realm and subject type; these cannot be parsed by older versions, so rewriting is
|
|
|
// not possible
|
|
|
- if (isCrossClusterAccess() && olderVersion.before(VERSION_CROSS_CLUSTER_ACCESS_REALM)) {
|
|
|
+ if (isCrossClusterAccess() && olderVersion.before(TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY)) {
|
|
|
throw new IllegalArgumentException(
|
|
|
"versions of Elasticsearch before ["
|
|
|
- + VERSION_CROSS_CLUSTER_ACCESS_REALM
|
|
|
+ + TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY
|
|
|
+ "] can't handle cross cluster access authentication and attempted to rewrite for ["
|
|
|
+ olderVersion
|
|
|
+ "]"
|
|
@@ -577,10 +574,10 @@ public final class Authentication implements ToXContentObject {
|
|
|
// cross cluster access introduced a new synthetic realm and subject type; these cannot be parsed by older versions, so rewriting we
|
|
|
// should not send them across the wire to older nodes
|
|
|
final boolean isCrossClusterAccess = effectiveSubject.getType() == Subject.Type.CROSS_CLUSTER_ACCESS;
|
|
|
- if (isCrossClusterAccess && out.getTransportVersion().before(VERSION_CROSS_CLUSTER_ACCESS_REALM)) {
|
|
|
+ if (isCrossClusterAccess && out.getTransportVersion().before(TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY)) {
|
|
|
throw new IllegalArgumentException(
|
|
|
"versions of Elasticsearch before ["
|
|
|
- + VERSION_CROSS_CLUSTER_ACCESS_REALM
|
|
|
+ + TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY
|
|
|
+ "] can't handle cross cluster access authentication and attempted to send to ["
|
|
|
+ out.getTransportVersion()
|
|
|
+ "]"
|
|
@@ -1291,8 +1288,8 @@ public final class Authentication implements ToXContentObject {
|
|
|
: "metadata must contain role descriptor for API key authentication";
|
|
|
assert metadata.containsKey(AuthenticationField.API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY)
|
|
|
: "metadata must contain limited role descriptor for API key authentication";
|
|
|
- if (authentication.getEffectiveSubject().getTransportVersion().onOrAfter(TRANSPORT_VERSION_API_KEYS_WITH_REMOTE_INDICES)
|
|
|
- && streamVersion.before(TRANSPORT_VERSION_API_KEYS_WITH_REMOTE_INDICES)) {
|
|
|
+ if (authentication.getEffectiveSubject().getTransportVersion().onOrAfter(TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY)
|
|
|
+ && streamVersion.before(TRANSPORT_VERSION_ADVANCED_REMOTE_CLUSTER_SECURITY)) {
|
|
|
metadata = new HashMap<>(metadata);
|
|
|
metadata.put(
|
|
|
AuthenticationField.API_KEY_ROLE_DESCRIPTORS_KEY,
|