Skip to content

Commit 8b33379

Browse files
committed
Merge branch 'feature/session-tokens' of github.com:ankit--sethi/elasticsearch into feature/session-tokens
2 parents 720bc14 + 491e378 commit 8b33379

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,10 +1387,7 @@ public static Authentication newCloudAccessTokenAuthentication(
13871387
) {
13881388
assert authResult.isAuthenticated() : "cloud access token authn result must be successful";
13891389
final User user = authResult.getValue();
1390-
return new Authentication(
1391-
new Subject(user, realmRef, TransportVersion.current(), authResult.getMetadata()),
1392-
TOKEN
1393-
);
1390+
return new Authentication(new Subject(user, realmRef, TransportVersion.current(), authResult.getMetadata()), TOKEN);
13941391
}
13951392

13961393
public static Authentication newCloudApiKeyAuthentication(AuthenticationResult<User> authResult, String nodeName) {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public void authenticate(Context context, ActionListener<AuthenticationResult<Au
5757
}
5858
AuthenticationToken token = context.getMostRecentAuthenticationToken();
5959
if (token != null) {
60-
var lis = new IteratingActionListener<>(listener,
60+
var lis = new IteratingActionListener<>(
61+
listener,
6162
getAuthConsumer(context),
6263
customAuthenticators,
6364
context.getThreadContext(),
@@ -68,7 +69,8 @@ public void authenticate(Context context, ActionListener<AuthenticationResult<Au
6869
}
6970
return result;
7071
},
71-
result -> result == null || result.getStatus() == AuthenticationResult.Status.CONTINUE);
72+
result -> result == null || result.getStatus() == AuthenticationResult.Status.CONTINUE
73+
);
7274
lis.run();
7375
return;
7476
}
@@ -93,8 +95,7 @@ private BiConsumer<CustomAuthenticator, ActionListener<AuthenticationResult<Auth
9395
iteratingListener.onResponse(AuthenticationResult.notHandled());
9496
}
9597
}, ex -> iteratingListener.onFailure(context.getRequest().exceptionProcessingRequest(ex, token))));
96-
}
97-
else {
98+
} else {
9899
iteratingListener.onResponse(null); // try the next custom authenticator
99100
}
100101
};

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public Authentication getAuthentication(AuthenticationResult<User> result, Strin
164164

165165
@Before
166166
public void init() {
167-
final Settings settings = Settings.builder()
168-
.build();
167+
final Settings settings = Settings.builder().build();
169168
threadContext = new ThreadContext(settings);
170169
}
171170

@@ -253,8 +252,9 @@ public void onFailure(Exception e) {
253252

254253
public void testAuthenticateWhenTokenSupportedByBothAuthenticatorsInChain() throws Exception {
255254

256-
PluggableAuthenticatorChain chain = new PluggableAuthenticatorChain(List.of(new TokenAAuthenticator("foo"),
257-
new TokenAAuthenticator("bar")));
255+
PluggableAuthenticatorChain chain = new PluggableAuthenticatorChain(
256+
List.of(new TokenAAuthenticator("foo"), new TokenAAuthenticator("bar"))
257+
);
258258
TestTokenA testToken = new TestTokenA("test-value");
259259

260260
Authenticator.Context context = createContext();
@@ -290,13 +290,14 @@ public void onFailure(Exception e) {
290290
assertThat(result.isAuthenticated(), equalTo(true));
291291

292292
Authentication auth = result.getValue();
293-
assertThat(auth.getEffectiveSubject().getUser().principal(), equalTo("token-a-auth-user-foo-test-value")); //id of first
293+
assertThat(auth.getEffectiveSubject().getUser().principal(), equalTo("token-a-auth-user-foo-test-value")); // id of first
294294
}
295295

296296
public void testAuthenticateWhenTokenSupportedByNoAuthenticatorsInChain() throws Exception {
297297

298-
PluggableAuthenticatorChain chain = new PluggableAuthenticatorChain(List.of(new TokenAAuthenticator("foo"),
299-
new TokenAAuthenticator("bar")));
298+
PluggableAuthenticatorChain chain = new PluggableAuthenticatorChain(
299+
List.of(new TokenAAuthenticator("foo"), new TokenAAuthenticator("bar"))
300+
);
300301
AuthenticationToken unknownToken = new AuthenticationToken() {
301302
@Override
302303
public String principal() {
@@ -347,15 +348,7 @@ public void onFailure(Exception e) {
347348
assertThat(result.getStatus(), equalTo(AuthenticationResult.Status.CONTINUE));
348349
}
349350

350-
351-
352351
private Authenticator.Context createContext() {
353-
return new Authenticator.Context(
354-
threadContext,
355-
null,
356-
null,
357-
true,
358-
null
359-
);
352+
return new Authenticator.Context(threadContext, null, null, true, null);
360353
}
361354
}

0 commit comments

Comments
 (0)