@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;
}
}
网友评论