美文网首页
资源服务器认证获取扩展用户信息

资源服务器认证获取扩展用户信息

作者: 尼尔君 | 来源:发表于2021-03-14 23:42 被阅读0次

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {

        DefaultAccessTokenConverter defaultAccessTokenConverter=new DefaultAccessTokenConverter();
        defaultAccessTokenConverter.setUserTokenConverter(myUserAuthenticationConverter);


        endpoints

                //认证管理器

                .authenticationManager(authenticationManager)

                //授权码服务
                .authorizationCodeServices(authorizationCodeServices())
                .reuseRefreshTokens(true)
                //令牌管理服务
                .tokenServices(authorizationServerTokenServices())

                .accessTokenConverter(defaultAccessTokenConverter)
                .allowedTokenEndpointRequestMethods(HttpMethod.POST);


    }

Converter

@Service
public class MyUserAuthenticationConverter extends DefaultUserAuthenticationConverter {


    @Override
    public Map<String, ?> convertUserAuthentication(Authentication authentication) {
        Map<String, Object> response = new LinkedHashMap();
        response.put("user_name", authentication);
        return response;
    }
}

相关文章

网友评论

      本文标题:资源服务器认证获取扩展用户信息

      本文链接:https://www.haomeiwen.com/subject/vilhcltx.html