springboot2稳定版本_springboot 最新稳定版
1、springboot 核心依赖最新版本:Spring Boot 2.3.3Spring Cloud Hoxton.SR8Spring Cloud Alibaba 2.2.2MybatisPlus 3.4.0Element 2.3.122、更新auth认证时,更改,RedisTokenStore记录登录用户,同时保证单点、多点登录,token认证成功之后对于相同的用户信息返回的token值是一样
1、springboot 核心依赖最新版本:
Spring Boot 2.3.3
Spring Cloud Hoxton.SR8
Spring Cloud Alibaba 2.2.2
MybatisPlus 3.4.0
Element 2.3.12
2、更新auth认证时,更改,RedisTokenStore记录登录用户,同时保证单点、多点登录,token认证成功之后对于相同的用户信息返回的token值是一样的,不适合在多地同时登录。
重写DefaultAuthenticationKeyGenerator
public class AuthenticationKeyGenerator extends DefaultAuthenticationKeyGenerator {private static final String CLIENT_ID = "client_id";
private static final String SCOPE = "scope";
private static final String USERNAME = "username";
@Override
public String extractKey(OAuth2Authentication authentication) {Map values = new LinkedHashMap();
OAuth2Request authorizationRequest = authentication.getOAuth2Request();
if (!authentication.isClientOnly()) {//在用户名后面添加时间戳,使每次的key都不一样
values.put(USERNAME, authentication.getName()+System.currentTimeMillis());
}values.put(CLIENT_ID, authorizationRequest.getClientId());
if (authorizationRequest.getScope() != null) {values.put(SCOPE, OAuth2Utils.formatParameterList(new TreeSet(authorizationRequest.getScope())));
}return generateKey(values);
}
}
public TokenStore tokenStore() {RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
redisTokenStore.setAuthenticationKeyGenerator(new MyAuthenticationKeyGenerator());
return redisTokenStore;
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)