Gar*_*ryF 6 spring oauth spring-security spring-security-oauth2
我正在尝试使用Spring Security Oauth2来保存我在数据库中存储的客户机密码.我可以看到JdbcClientDetailsService有一种setPasswordEncoder方法(如本问题所述).但是,ClientDetailsServiceConfigureron AuthorizationServerConfigurerAdapter没有显示任何设置密码编码器的明显方法.有谁知道如何做到这一点?我已经包含了授权服务器配置:
@Configuration
@EnableAuthorizationServer
public static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private TokenStore tokenStore;
@Autowired
private UserApprovalHandler userApprovalHandler;
@Autowired
private ClientDetailsService clientDetailsService;
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.jdbc(dataSource);
}
@Bean
public TokenStore tokenStore() {
return new JdbcTokenStore(dataSource);
}
@Bean
public TokenApprovalStore tokenApprovalStore() {
TokenApprovalStore tokenApprovalStore = new TokenApprovalStore();
tokenApprovalStore.setTokenStore(tokenStore);
return tokenApprovalStore;
}
@Bean
public UserApprovalHandler userApprovalHandler() {
LocalUserApprovalHandler handler = new LocalUserApprovalHandler();
handler.setApprovalStore(tokenApprovalStore());
handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
handler.setClientDetailsService(clientDetailsService);
handler.setUseApprovalStore(true);
return handler;
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
endpoints.tokenStore(tokenStore)
.userApprovalHandler(userApprovalHandler)
.authenticationManager(authenticationManager);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer oauthServer) {
oauthServer.realm("abcdefgh/client");
}
}
Run Code Online (Sandbox Code Playgroud)
从版本2.0.5中,passwordEncoder(...)方法现在上都可用ClientDetailsServiceConfigurer和AuthorizationServerSecurityConfigurer延伸时被提供AuthorizationServerConfigurerAdapter。PasswordEncoder两者都使用相同的实现,并且配置相对容易。
| 归档时间: |
|
| 查看次数: |
5016 次 |
| 最近记录: |