修复redis-cluster模式下删除token失败问题
This commit is contained in:
+6
-11
@@ -360,16 +360,14 @@ public class CustomRedisTokenStore implements TokenStore {
|
|||||||
byte[] accessToRefreshKey = serializeKey(ACCESS_TO_REFRESH + tokenValue);
|
byte[] accessToRefreshKey = serializeKey(ACCESS_TO_REFRESH + tokenValue);
|
||||||
RedisConnection conn = getConnection();
|
RedisConnection conn = getConnection();
|
||||||
try {
|
try {
|
||||||
|
byte[] access = conn.get(accessKey);
|
||||||
|
byte[] auth = conn.get(authKey);
|
||||||
conn.openPipeline();
|
conn.openPipeline();
|
||||||
conn.get(accessKey);
|
|
||||||
conn.get(authKey);
|
|
||||||
conn.del(accessKey);
|
conn.del(accessKey);
|
||||||
conn.del(accessToRefreshKey);
|
conn.del(accessToRefreshKey);
|
||||||
// Don't remove the refresh token - it's up to the caller to do that
|
// Don't remove the refresh token - it's up to the caller to do that
|
||||||
conn.del(authKey);
|
conn.del(authKey);
|
||||||
List<Object> results = conn.closePipeline();
|
conn.closePipeline();
|
||||||
byte[] access = (byte[]) results.get(0);
|
|
||||||
byte[] auth = (byte[]) results.get(1);
|
|
||||||
|
|
||||||
OAuth2Authentication authentication = deserializeAuthentication(auth);
|
OAuth2Authentication authentication = deserializeAuthentication(auth);
|
||||||
if (authentication != null) {
|
if (authentication != null) {
|
||||||
@@ -471,20 +469,17 @@ public class CustomRedisTokenStore implements TokenStore {
|
|||||||
|
|
||||||
private void removeAccessTokenUsingRefreshToken(String refreshToken) {
|
private void removeAccessTokenUsingRefreshToken(String refreshToken) {
|
||||||
byte[] key = serializeKey(REFRESH_TO_ACCESS + refreshToken);
|
byte[] key = serializeKey(REFRESH_TO_ACCESS + refreshToken);
|
||||||
List<Object> results = null;
|
|
||||||
RedisConnection conn = getConnection();
|
RedisConnection conn = getConnection();
|
||||||
|
byte[] bytes = null;
|
||||||
try {
|
try {
|
||||||
conn.openPipeline();
|
bytes = conn.get(key);
|
||||||
conn.get(key);
|
|
||||||
conn.del(key);
|
conn.del(key);
|
||||||
results = conn.closePipeline();
|
|
||||||
} finally {
|
} finally {
|
||||||
conn.close();
|
conn.close();
|
||||||
}
|
}
|
||||||
if (results == null) {
|
if (bytes == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
byte[] bytes = (byte[]) results.get(0);
|
|
||||||
String accessToken = deserializeString(bytes);
|
String accessToken = deserializeString(bytes);
|
||||||
if (accessToken != null) {
|
if (accessToken != null) {
|
||||||
removeAccessToken(accessToken);
|
removeAccessToken(accessToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user