Skip to content

Commit 873d0ec

Browse files
authored
Fix potential bug in concurrent token refresh support (#53668) (#53705)
Ensure that we do not proceed execution after calling the listerer's onFailure
1 parent 7a12300 commit 873d0ec

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
@@ -1071,9 +1071,10 @@ void decryptAndReturnSupersedingTokens(String refreshToken, RefreshTokenStatus r
10711071
if (decryptedTokens.length != 2) {
10721072
logger.warn("Decrypted tokens string is not correctly formatted");
10731073
listener.onFailure(invalidGrantException("could not refresh the requested token"));
1074+
} else {
1075+
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
1076+
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
10741077
}
1075-
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
1076-
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
10771078
} catch (GeneralSecurityException | IOException e) {
10781079
logger.warn("Could not get stored superseding token values", e);
10791080
listener.onFailure(invalidGrantException("could not refresh the requested token"));

0 commit comments

Comments
 (0)