Skip to content

Commit 4a32400

Browse files
committed
code review stuff
1 parent 01a3f18 commit 4a32400

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authc/Authentication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,9 @@ public static Authentication newCloudAccessTokenAuthentication(
13811381
Authentication.RealmRef realmRef
13821382
) {
13831383
assert authResult.isAuthenticated() : "cloud access token authn result must be successful";
1384-
final User apiKeyUser = authResult.getValue();
1384+
final User user = authResult.getValue();
13851385
return new Authentication(
1386-
new Subject(apiKeyUser, realmRef, TransportVersion.current(), authResult.getMetadata()),
1386+
new Subject(user, realmRef, TransportVersion.current(), authResult.getMetadata()),
13871387
AuthenticationType.TOKEN
13881388
);
13891389
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ Collection<Object> createComponents(
10811081
}
10821082

10831083
final List<CustomAuthenticator> customAuthenticators = getCustomAuthenticatorFromExtensions(extensionComponents);
1084+
components.addAll(customAuthenticators);
10841085

10851086
authcService.set(
10861087
new AuthenticationService(

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/PluggableAuthenticatorChain.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
import org.elasticsearch.xpack.core.security.authc.apikey.CustomAuthenticator;
1515

1616
import java.util.List;
17+
import java.util.Objects;
1718

1819
public class PluggableAuthenticatorChain implements Authenticator {
1920

20-
public static final PluggableAuthenticatorChain EMPTY = new PluggableAuthenticatorChain(List.of());
21-
2221
private final List<CustomAuthenticator> customAuthenticators;
2322

2423
public PluggableAuthenticatorChain(List<CustomAuthenticator> customAuthenticators) {
25-
this.customAuthenticators = customAuthenticators;
24+
this.customAuthenticators = Objects.requireNonNull(customAuthenticators);
2625
}
2726

2827
@Override
@@ -56,6 +55,7 @@ public void authenticate(Context context, ActionListener<AuthenticationResult<Au
5655
}
5756
AuthenticationToken token = context.getMostRecentAuthenticationToken();
5857
if (token != null) {
58+
//TODO switch to IteratingActionListener
5959
for (CustomAuthenticator customAuthenticator : customAuthenticators) {
6060
if (customAuthenticator.supports(token)) {
6161
customAuthenticator.authenticate(token, ActionListener.wrap(response -> {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.junit.Before;
3939

4040
import java.io.IOException;
41+
import java.util.Collections;
4142
import java.util.List;
4243

4344
import static org.elasticsearch.test.ActionListenerUtils.anyActionListener;
@@ -91,7 +92,7 @@ public void init() {
9192
oAuth2TokenAuthenticator = mock(OAuth2TokenAuthenticator.class);
9293
apiKeyAuthenticator = mock(ApiKeyAuthenticator.class);
9394
realmsAuthenticator = mock(RealmsAuthenticator.class);
94-
PluggableAuthenticatorChain pluggableAuthenticatorChain = PluggableAuthenticatorChain.EMPTY;
95+
PluggableAuthenticatorChain pluggableAuthenticatorChain = new PluggableAuthenticatorChain(Collections.emptyList());
9596

9697
when(realms.getActiveRealms()).thenReturn(List.of(mock(Realm.class)));
9798
when(realms.getUnlicensedRealms()).thenReturn(List.of());

0 commit comments

Comments
 (0)