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<String, String> values = new LinkedHashMap<String, String>();

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<String>(authorizationRequest.getScope())));

}

    return generateKey(values);

}
}

public TokenStore tokenStore() {

RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);

redisTokenStore.setAuthenticationKeyGenerator(new MyAuthenticationKeyGenerator());
return redisTokenStore;
}