@Bean
public TokenStore tokenStore() {
RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
tokenStore.setPrefix(SecurityConstants.abc);
tokenStore.setAuthenticationKeyGenerator(new DefaultAuthenticationKeyGenerator() {
@Override
public String extractKey(OAuth2Authentication authentication) {
return super.extractKey(authentication) + StrUtil.COLON + TenantContextHolder.getTenantId();
}
});
return tokenStore;
默认时常为12个小时,怎样改这个时常啊
public class JwtAccessToken extends JwtAccessTokenConverter {
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
DefaultOAuth2AccessToken defaultOAuth2AccessToken = new DefaultOAuth2AccessToken(accessToken);
//设置过期时间
defaultOAuth2AccessToken.setExpiration(new Date(System.currentTimeMillis() + 1000 * 3600 * 24));
// 设置额外用户信息
User user = ((User) authentication.getPrincipal());
List<String> authorities = new ArrayList<>();
user.getAuthorityList().forEach(authority -> authorities.add(authority.getAuthority()));
// 将用户信息添加到token额外信息中
defaultOAuth2AccessToken.getAdditionalInformation().put("uuid", user.getUuid());
defaultOAuth2AccessToken.getAdditionalInformation().put("authorities", authorities);
return super.enhance(defaultOAuth2AccessToken, authentication);
}
}