一、Spring Security Oauth2 中实现TokenEnhancer向jwt中添加额外信息
1.你要实现TokenEhancer(令牌增强器)中的 ehance方法,然后添加自定义内容
定制TokenEhancer
public class CustomTokenEnhancer implements TokenEnhancer {
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
User user = (User) authentication.getPrincipal();
final Map<String, Object> additionalInfo = new