Skip to content

Commit 570de53

Browse files
authored
Remove transport version V_7_0_0 (#135874)
ES-12334
1 parent 391e78d commit 570de53

File tree

6 files changed

+3
-307
lines changed

6 files changed

+3
-307
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static TransportVersion def(int id) {
5353
}
5454

5555
// TODO: ES-10337 we can remove all transport versions earlier than 8.18
56-
public static final TransportVersion V_7_0_0 = def(7_00_00_99);
5756
public static final TransportVersion V_7_1_0 = def(7_01_00_99);
5857
public static final TransportVersion V_7_2_0 = def(7_02_00_99);
5958
public static final TransportVersion V_7_3_0 = def(7_03_00_99);

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationSerializationTests.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,17 @@
1313
import org.elasticsearch.test.ESTestCase;
1414
import org.elasticsearch.test.TransportVersionUtils;
1515
import org.elasticsearch.transport.RemoteClusterPortSettings;
16-
import org.elasticsearch.xpack.core.security.authc.support.AuthenticationContextSerializer;
1716
import org.elasticsearch.xpack.core.security.user.ElasticUser;
1817
import org.elasticsearch.xpack.core.security.user.InternalUsers;
1918
import org.elasticsearch.xpack.core.security.user.KibanaSystemUser;
2019
import org.elasticsearch.xpack.core.security.user.KibanaUser;
2120
import org.elasticsearch.xpack.core.security.user.User;
2221

23-
import java.io.IOException;
2422
import java.util.Arrays;
2523
import java.util.Map;
2624

2725
import static org.elasticsearch.xpack.core.security.authc.Authentication.AuthenticationSerializationHelper;
28-
import static org.hamcrest.Matchers.arrayContaining;
2926
import static org.hamcrest.Matchers.containsString;
30-
import static org.hamcrest.Matchers.emptyArray;
3127
import static org.hamcrest.Matchers.equalTo;
3228
import static org.hamcrest.Matchers.is;
3329
import static org.hamcrest.Matchers.not;
@@ -232,47 +228,4 @@ public void testReservedUserSerialization() throws Exception {
232228

233229
assertEquals(kibanaSystemUser, readFrom);
234230
}
235-
236-
public void testRolesRemovedFromUserForLegacyApiKeys() throws IOException {
237-
TransportVersion transportVersion = TransportVersionUtils.randomVersionBetween(
238-
random(),
239-
TransportVersions.V_7_0_0,
240-
TransportVersions.V_7_8_0
241-
);
242-
Subject authenticatingSubject = new Subject(
243-
new User("foo", "role"),
244-
new Authentication.RealmRef(AuthenticationField.API_KEY_REALM_NAME, AuthenticationField.API_KEY_REALM_TYPE, "node"),
245-
transportVersion,
246-
Map.of(AuthenticationField.API_KEY_ID_KEY, "abc")
247-
);
248-
Subject effectiveSubject = new Subject(
249-
new User("bar", "role"),
250-
new Authentication.RealmRef("native", "native", "node"),
251-
transportVersion,
252-
Map.of()
253-
);
254-
255-
{
256-
Authentication actual = AuthenticationContextSerializer.decode(
257-
Authentication.doEncode(authenticatingSubject, authenticatingSubject, Authentication.AuthenticationType.API_KEY)
258-
);
259-
assertThat(actual.getAuthenticatingSubject().getUser().roles(), is(emptyArray()));
260-
}
261-
262-
{
263-
Authentication actual = AuthenticationContextSerializer.decode(
264-
Authentication.doEncode(effectiveSubject, authenticatingSubject, Authentication.AuthenticationType.API_KEY)
265-
);
266-
assertThat(actual.getAuthenticatingSubject().getUser().roles(), is(emptyArray()));
267-
assertThat(actual.getEffectiveSubject().getUser().roles(), is(arrayContaining("role")));
268-
}
269-
270-
{
271-
// do not strip roles for authentication methods other than API key
272-
Authentication actual = AuthenticationContextSerializer.decode(
273-
Authentication.doEncode(effectiveSubject, effectiveSubject, Authentication.AuthenticationType.REALM)
274-
);
275-
assertThat(actual.getAuthenticatingSubject().getUser().roles(), is(arrayContaining("role")));
276-
}
277-
}
278231
}

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/AuthenticationTests.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,9 +1321,7 @@ public static Authentication randomAuthentication(User user, RealmRef realmRef,
13211321
if (realmRef == null) {
13221322
realmRef = randomRealmRef(false);
13231323
}
1324-
// If the realm is expected to have a domain, we need a version that's at least compatible with domains
1325-
final TransportVersion minVersion = realmRef.getDomain() != null ? Authentication.VERSION_REALM_DOMAINS : TransportVersions.V_7_0_0;
1326-
final TransportVersion version = TransportVersionUtils.randomVersionBetween(random(), minVersion, TransportVersion.current());
1324+
final TransportVersion version = TransportVersionUtils.randomCompatibleVersion(random());
13271325
final Map<String, Object> metadata;
13281326
if (randomBoolean()) {
13291327
metadata = Map.of(randomAlphaOfLengthBetween(3, 8), randomAlphaOfLengthBetween(3, 8));
@@ -1336,11 +1334,7 @@ public static Authentication randomAuthentication(User user, RealmRef realmRef,
13361334
}
13371335

13381336
public static Authentication randomApiKeyAuthentication(User user, String apiKeyId) {
1339-
return randomApiKeyAuthentication(
1340-
user,
1341-
apiKeyId,
1342-
TransportVersionUtils.randomVersionBetween(random(), TransportVersions.V_7_0_0, TransportVersion.current())
1343-
);
1337+
return randomApiKeyAuthentication(user, apiKeyId, TransportVersionUtils.randomCompatibleVersion(random()));
13441338
}
13451339

13461340
public static Authentication randomApiKeyAuthentication(User user, String apiKeyId, TransportVersion version) {

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authc/SubjectTests.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@
88
package org.elasticsearch.xpack.core.security.authc;
99

1010
import org.elasticsearch.TransportVersion;
11-
import org.elasticsearch.TransportVersions;
1211
import org.elasticsearch.common.Strings;
1312
import org.elasticsearch.common.bytes.BytesArray;
1413
import org.elasticsearch.common.bytes.BytesReference;
1514
import org.elasticsearch.common.settings.Settings;
1615
import org.elasticsearch.common.util.ArrayUtils;
1716
import org.elasticsearch.test.ESTestCase;
18-
import org.elasticsearch.test.TransportVersionUtils;
1917
import org.elasticsearch.xpack.core.security.action.apikey.ApiKey;
2018
import org.elasticsearch.xpack.core.security.authc.service.ServiceAccountSettings;
2119
import org.elasticsearch.xpack.core.security.authz.RoleDescriptorsIntersection;
2220
import org.elasticsearch.xpack.core.security.authz.store.RoleKey;
2321
import org.elasticsearch.xpack.core.security.authz.store.RoleReference;
2422
import org.elasticsearch.xpack.core.security.authz.store.RoleReference.ApiKeyRoleReference;
25-
import org.elasticsearch.xpack.core.security.authz.store.RoleReference.BwcApiKeyRoleReference;
2623
import org.elasticsearch.xpack.core.security.authz.store.RoleReference.FixedRoleReference;
2724
import org.elasticsearch.xpack.core.security.authz.store.RoleReference.NamedRoleReference;
2825
import org.elasticsearch.xpack.core.security.authz.store.RoleReference.ServiceAccountRoleReference;
@@ -32,7 +29,6 @@
3229
import org.elasticsearch.xpack.core.security.user.User;
3330

3431
import java.util.Arrays;
35-
import java.util.Collections;
3632
import java.util.HashMap;
3733
import java.util.List;
3834
import java.util.Map;
@@ -287,50 +283,6 @@ private static void expectFixedReferenceAtIndex(int index, List<RoleReference> r
287283
assertThat(fixedRoleReference.id(), equalTo(expectedKey));
288284
}
289285

290-
public void testGetRoleReferencesForApiKeyBwc() {
291-
Map<String, Object> authMetadata = new HashMap<>();
292-
final String apiKeyId = randomAlphaOfLength(12);
293-
authMetadata.put(AuthenticationField.API_KEY_ID_KEY, apiKeyId);
294-
authMetadata.put(AuthenticationField.API_KEY_NAME_KEY, randomBoolean() ? null : randomAlphaOfLength(12));
295-
boolean emptyApiKeyRoleDescriptor = randomBoolean();
296-
Map<String, Object> roleARDMap = Map.of("cluster", List.of("monitor"));
297-
authMetadata.put(
298-
API_KEY_ROLE_DESCRIPTORS_KEY,
299-
(emptyApiKeyRoleDescriptor)
300-
? randomFrom(Arrays.asList(null, Collections.emptyMap()))
301-
: Collections.singletonMap("a role", roleARDMap)
302-
);
303-
304-
Map<String, Object> limitedRdMap = Map.of("cluster", List.of("all"));
305-
authMetadata.put(API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY, Collections.singletonMap("limited role", limitedRdMap));
306-
307-
final Subject subject = new Subject(
308-
new User("joe"),
309-
new Authentication.RealmRef(API_KEY_REALM_NAME, API_KEY_REALM_TYPE, "node"),
310-
TransportVersionUtils.randomVersionBetween(random(), TransportVersions.V_7_0_0, TransportVersions.V_7_8_1),
311-
authMetadata
312-
);
313-
314-
final RoleReferenceIntersection roleReferenceIntersection = subject.getRoleReferenceIntersection(getAnonymousUser());
315-
final List<RoleReference> roleReferences = roleReferenceIntersection.getRoleReferences();
316-
317-
if (emptyApiKeyRoleDescriptor) {
318-
assertThat(roleReferences, contains(isA(BwcApiKeyRoleReference.class)));
319-
final BwcApiKeyRoleReference limitedByRoleReference = (BwcApiKeyRoleReference) roleReferences.get(0);
320-
assertThat(limitedByRoleReference.getApiKeyId(), equalTo(apiKeyId));
321-
assertThat(limitedByRoleReference.getRoleDescriptorsMap(), equalTo(authMetadata.get(API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY)));
322-
} else {
323-
assertThat(roleReferences, contains(isA(BwcApiKeyRoleReference.class), isA(BwcApiKeyRoleReference.class)));
324-
final BwcApiKeyRoleReference roleReference = (BwcApiKeyRoleReference) roleReferences.get(0);
325-
assertThat(roleReference.getApiKeyId(), equalTo(apiKeyId));
326-
assertThat(roleReference.getRoleDescriptorsMap(), equalTo(authMetadata.get(API_KEY_ROLE_DESCRIPTORS_KEY)));
327-
328-
final BwcApiKeyRoleReference limitedByRoleReference = (BwcApiKeyRoleReference) roleReferences.get(1);
329-
assertThat(limitedByRoleReference.getApiKeyId(), equalTo(apiKeyId));
330-
assertThat(limitedByRoleReference.getRoleDescriptorsMap(), equalTo(authMetadata.get(API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY)));
331-
}
332-
}
333-
334286
public void testGetFleetApiKeyRoleReferenceBwcBugFix() {
335287
final BytesReference roleBytes = new BytesArray("{\"a role\": {\"cluster\": [\"all\"]}}");
336288
final BytesReference limitedByRoleBytes = new BytesArray("{}");

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/TokenServiceTests.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,7 @@ public void setupClient() {
243243
}
244244

245245
private static DiscoveryNode addAnother7071DataNode(ClusterService clusterService) {
246-
Version version;
247-
TransportVersion transportVersion;
248-
if (randomBoolean()) {
249-
version = Version.V_7_0_0;
250-
transportVersion = TransportVersions.V_7_0_0;
251-
} else {
252-
version = Version.V_7_1_0;
253-
transportVersion = TransportVersions.V_7_1_0;
254-
}
255-
return addAnotherDataNodeWithVersion(clusterService, version, transportVersion);
246+
return addAnotherDataNodeWithVersion(clusterService, Version.V_7_1_0, TransportVersions.V_7_1_0);
256247
}
257248

258249
private static DiscoveryNode addAnotherPre8500DataNode(ClusterService clusterService) {

0 commit comments

Comments
 (0)