启用Spring OAuth2 ResourceServer将禁用UsernamePasswordAuthenticationFilter

启用Spring OAuth2 ResourceServer将禁用UsernamePasswordAuthenticationFilter,authentication,spring-security,spring-security-oauth2,Authentication,Spring Security,Spring Security Oauth2,我的网站安全配置适配器中有以下内容: protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/login.jsp").permitAll() .anyRequest().authenticated() .and() .exception

我的
网站安全配置适配器中有以下内容:

protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
            .antMatchers("/login.jsp").permitAll()
            .anyRequest().authenticated()
            .and()
        .exceptionHandling()
            .accessDeniedPage("/login.jsp?authorization_error=true")
            .and()
        .csrf()
            .disable()
        .formLogin()
            .loginProcessingUrl("/login")
            .loginPage("/login.jsp")
            .failureUrl("/login.jsp?authentication_error=true");
}
我有一个OAuth2客户端(用PHP编写),可以在获得有效的访问令牌之前重定向到/login

然后我尝试启用我的
资源服务器ConfigureRadapter

@Configuration
@EnableResourceServer
protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(ResourceServerSecurityConfigurer resources)
            throws Exception {
        resources.resourceId("myResource").stateless(false);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
            .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED)
                .and()
            .requestMatchers()
                .antMatchers("/me")
                .and()
            .authorizeRequests()
                .antMatchers("/me").access("#oauth2.hasScope('email')");
    }

}
启用
ResourceServer
后,将永远不会调用
UsernamePasswordAuthenticationFilter
,转到/login返回HTTP 404错误


我多次阅读Spring OAuth2应用程序Sparkr2和tonr2示例,但我无法找出代码的错误。

这是一个很难追踪的错误

我的代码最初使用的是Spring安全版本4.0.2.RELEASE和Spring版本4.2.2.RELEASE。一旦我将maven pom.xml更改为使用Spring安全版本3.2.8.RELEASE和Spring版本4.1.8.RELEASE,我的代码就可以工作了

这可能与以下错误有关: