spring-security-auth2的疑难杂症
原创小于 1 分钟
进行IllegalStateException, UserDetailsService is required.
在进行走refresh_token的时候需要UserDetailsService
具体代码
@Autowired
private UserDetailsService userDetailsServiceBean;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore()).userDetailsService(userDetailsServiceBean);
}
要支持password授权模式,必须要加入认证管理器(AuthenticationManager)
具体代码
@Autowired
private AuthenticationManager authenticationManagerBean;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.authenticationManager(authenticationManagerBean)
// 保存oauth_access_token,oauth_refresh_token
.tokenStore(tokenStore()).userDetailsService(userDetailsServiceBean)
// 保存auth_code
.authorizationCodeServices(authorizationCodeServices())
// 保存oauth_approvals
.approvalStore(approvalStore());
}