提交 782b5e07 编写于 作者: zlt2000's avatar zlt2000

修复redis-cluster模式下删除token失败问题

上级 68e73ab9
...@@ -360,16 +360,14 @@ public class CustomRedisTokenStore implements TokenStore { ...@@ -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 { ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册