小编Ali*_*dam的帖子

使用@EnableAuthorizationServer时,如何在HTTP BasicAuthenticationFilter之后添加过滤器

我正在尝试查看以下文档:https://github.com/spring-projects/spring-security-oauth/blob/f25592e682303b0cf89e1d7555174bac18e174df/docs/oauth2.md#mapping-user-roles-to-scopes

在文档中,它说为了将用户角色映射到范围,并设置在checkUserScopes=trueDefaultOAuth2RequestFactory,我们需要TokenEndpointAuthenticationFilter在HTTP之后添加过滤器BasicAuthenticationFilter.我想知道如何做到这一点.

这是我的AuthorizationServer的样子:

@Configuration
@EnableAuthorizationServer
protected static class OAuth2Config extends
        AuthorizationServerConfigurerAdapter {

    @Autowired
    private AuthenticationManager authenticationManager;

    @Autowired
    private OAuth2RequestFactory requestFactory;

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
        endpoints.authenticationManager(authenticationManager);
        endpoints.requestFactory(requestFactory);
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients)
            throws Exception {
        clients.withClientDetails(clientDetailsService());
    }

    @Override
    public void configure(AuthorizationServerSecurityConfigurer oauthServer)
            throws Exception {
        oauthServer.checkTokenAccess("isAuthenticated()");
    }

    @Bean
    public ClientDetailsService clientDetailsService() {

        Map<String, ClientDetails> clientDetailsStore = new HashMap<String, ClientDetails>();

        Collection<String> scope = new HashSet<String>();
        scope.add("user");
        scope.add("admin");

        Collection<String> …
Run Code Online (Sandbox Code Playgroud)

java spring-security spring-security-oauth2

11
推荐指数
1
解决办法
4460
查看次数