Skip to content

Commit b130eb5

Browse files
authored
Fix potential bug in concurrent token refresh support (#53668) (#53706)
Ensure that we do not proceed execution after calling the listerer's onFailure
1 parent 70d2c7c commit b130eb5

File tree

1 file changed

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

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,9 +1068,10 @@ void decryptAndReturnSupersedingTokens(String refreshToken, RefreshTokenStatus r
10681068
if (decryptedTokens.length != 2) {
10691069
logger.warn("Decrypted tokens string is not correctly formatted");
10701070
listener.onFailure(invalidGrantException("could not refresh the requested token"));
1071+
} else {
1072+
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
1073+
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
10711074
}
1072-
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
1073-
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
10741075
} catch (GeneralSecurityException | IOException e) {
10751076
logger.warn("Could not get stored superseding token values", e);
10761077
listener.onFailure(invalidGrantException("could not refresh the requested token"));

0 commit comments

Comments
 (0)