Skip to content

Commit 2a79c46

Browse files
committed
Ensure that ActionListener is called exactly once
This bug was introduced in #36893 and had the effect that execution would continue after calling onFailure on the the listener in checkIfTokenIsValid in the case that the token is expired. In a case of many consecutive requests this could lead to the unwelcome side effect of an expired access token producing a successful authentication response.
1 parent 38b698d commit 2a79c46

File tree

1 file changed

+1
-2
lines changed
  • x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc

1 file changed

+1
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,7 @@ private void checkIfTokenIsValid(UserToken userToken, ActionListener<UserToken>
10171017
Instant currentTime = clock.instant();
10181018
if (currentTime.isAfter(userToken.getExpirationTime())) {
10191019
listener.onFailure(traceLog("validate token", userToken.getId(), expiredTokenException()));
1020-
}
1021-
if (securityIndex.indexExists() == false) {
1020+
} else if (securityIndex.indexExists() == false) {
10221021
// index doesn't exist so the token is considered invalid as we cannot verify its validity
10231022
logger.warn("failed to validate token [{}] since the security index doesn't exist", userToken.getId());
10241023
listener.onResponse(null);

0 commit comments

Comments
 (0)