Skip to content

Commit

Permalink
Fix potential bug in concurrent token refresh support (elastic#53668)
Browse files Browse the repository at this point in the history
Ensure that we do not proceed execution after calling the
listerer's onFailure
  • Loading branch information
jkakavas committed Mar 18, 2020
1 parent 70d2c7c commit e655a09
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1068,9 +1068,10 @@ void decryptAndReturnSupersedingTokens(String refreshToken, RefreshTokenStatus r
if (decryptedTokens.length != 2) {
logger.warn("Decrypted tokens string is not correctly formatted");
listener.onFailure(invalidGrantException("could not refresh the requested token"));
} else {
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
}
listener.onResponse(new Tuple<>(prependVersionAndEncodeAccessToken(refreshTokenStatus.getVersion(), decryptedTokens[0]),
prependVersionAndEncodeRefreshToken(refreshTokenStatus.getVersion(), decryptedTokens[1])));
} catch (GeneralSecurityException | IOException e) {
logger.warn("Could not get stored superseding token values", e);
listener.onFailure(invalidGrantException("could not refresh the requested token"));
Expand Down

0 comments on commit e655a09

Please sign in to comment.