我在授权服务器中使用了JDBC令牌存储。但我不知道消费者令牌服务。有人能解释一下吗?如何使用消费者令牌服务撤销访问令牌?
授权配置
@Configuration
@EnableAuthorizationServer
public class OAuthServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private UserDetailsServiceImpl userDetailsService;
@Autowired
AuthenticationManager authenticationManager;
@Autowired
Environment environment;
@Autowired
@Qualifier("dataSourceApi")
DataSource dataSource;
@Primary
@Bean
public ConsumerTokenServices defaultTokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
return defaultTokenServices;
}
@Bean
public JdbcTokenStore tokenStore() {
return new JdbcTokenStore(dataSource);
}
@Bean
public JdbcClientDetailsService jdbcClientDetailsService() {
return new JdbcClientDetailsService(dataSource);
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore()).authenticationManager(authenticationManager);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.jdbc(dataSource);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
}
}
答案 0 :(得分:1)
旧帖子,但这应该有未来开发者的答案。
当用户注销时,访问令牌应该(必须?!)被撤销。这可以通过
完成tokenServices.revokeToken(tokenId);