Merge pull request #7329 from EightMonth/springboot3_sas

Revert "修复redis序列化认证信息问题"
pull/7361/head
JEECG 2 months ago committed by GitHub
commit 48e20b2af5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -43,11 +43,9 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization
if (isState(authorization)) {
String token = authorization.getAttribute("state");
RedisSerializer<?> redisSerializer = redisTemplate.getValueSerializer();
redisTemplate.setValueSerializer(RedisSerializer.java());
redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.STATE, token), authorization, TIMEOUT,
TimeUnit.MINUTES);
redisTemplate.setValueSerializer(redisSerializer);
}
if (isCode(authorization)) {
@ -56,27 +54,22 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization
OAuth2AuthorizationCode authorizationCodeToken = authorizationCode.getToken();
long between = ChronoUnit.MINUTES.between(authorizationCodeToken.getIssuedAt(),
authorizationCodeToken.getExpiresAt());
RedisSerializer<?> redisSerializer = redisTemplate.getValueSerializer();
redisTemplate.setValueSerializer(RedisSerializer.java());
redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.CODE, authorizationCodeToken.getTokenValue()),
authorization, between, TimeUnit.MINUTES);
redisTemplate.setValueSerializer(redisSerializer);
}
if (isRefreshToken(authorization)) {
OAuth2RefreshToken refreshToken = authorization.getRefreshToken().getToken();
long between = ChronoUnit.SECONDS.between(refreshToken.getIssuedAt(), refreshToken.getExpiresAt());
RedisSerializer<?> redisSerializer = redisTemplate.getValueSerializer();
redisTemplate.setValueSerializer(RedisSerializer.java());
redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.REFRESH_TOKEN, refreshToken.getTokenValue()),
authorization, between, TimeUnit.SECONDS);
redisTemplate.setValueSerializer(redisSerializer);
}
if (isAccessToken(authorization)) {
OAuth2AccessToken accessToken = authorization.getAccessToken().getToken();
long between = ChronoUnit.SECONDS.between(accessToken.getIssuedAt(), accessToken.getExpiresAt());
RedisSerializer<?> redisSerializer = redisTemplate.getValueSerializer();
redisTemplate.setValueSerializer(RedisSerializer.java());
redisTemplate.opsForValue().set(buildKey(OAuth2ParameterNames.ACCESS_TOKEN, accessToken.getTokenValue()),
authorization, between, TimeUnit.SECONDS);
@ -84,7 +77,6 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization
// 扩展记录 access-token 、username 的关系 1::token::username::admin::xxx
String tokenUsername = String.format("%s::%s::%s", AUTHORIZATION, authorization.getPrincipalName(), accessToken.getTokenValue());
redisTemplate.opsForValue().set(tokenUsername, accessToken.getTokenValue(), between, TimeUnit.SECONDS);
redisTemplate.setValueSerializer(redisSerializer);
}
}
@ -133,11 +125,8 @@ public class JeecgRedisOAuth2AuthorizationService implements OAuth2Authorization
public OAuth2Authorization findByToken(String token, @Nullable OAuth2TokenType tokenType) {
Assert.hasText(token, "token cannot be empty");
Assert.notNull(tokenType, "tokenType cannot be empty");
RedisSerializer<?> redisSerializer = redisTemplate.getValueSerializer();
redisTemplate.setValueSerializer(RedisSerializer.java());
OAuth2Authorization oAuth2Authorization = (OAuth2Authorization) redisTemplate.opsForValue().get(buildKey(tokenType.getValue(), token));
redisTemplate.setValueSerializer(redisSerializer);
return oAuth2Authorization;
return (OAuth2Authorization) redisTemplate.opsForValue().get(buildKey(tokenType.getValue(), token));
}
private String buildKey(String type, String id) {

Loading…
Cancel
Save