0%

spring-security-auth2的疑难杂症

进行IllegalStateException, UserDetailsService is required.

在进行走refresh_token的时候需要UserDetailsService

具体代码

1
2
3
4
5
6
7
8
9

@Autowired
private UserDetailsService userDetailsServiceBean;


@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore()).userDetailsService(userDetailsServiceBean);
}

要支持password授权模式,必须要加入认证管理器(AuthenticationManager)

具体代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

@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());
}

-------------本文结束感谢你的阅读---------