Spring security Spring安全性-成功身份验证后没有访问权限

Spring security Spring安全性-成功身份验证后没有访问权限,spring-security,Spring Security,我正在尝试包含web应用程序的身份验证。 用户已通过登录页面成功登录,但他们仍然无法访问任何其他页面 起初我认为问题与Active Directory有关,但在切换到内存内身份验证进行调试后,我发现两者都不能正常工作 这是我的安全配置: @EnableWebSecurity @Configuration public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override protecte

我正在尝试包含web应用程序的身份验证。 用户已通过登录页面成功登录,但他们仍然无法访问任何其他页面

起初我认为问题与Active Directory有关,但在切换到内存内身份验证进行调试后,我发现两者都不能正常工作

这是我的安全配置:

@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {

    http
        .csrf()
            .disable()
        .authorizeRequests()
            .antMatchers("/css/**").permitAll()
            .antMatchers("/js/**").permitAll()
            .antMatchers("/img/**").permitAll()
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .and()
        .logout()
            .permitAll();
    }

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("user").password("test").roles("USER");
    }

}
登录后,我在日志中获得身份验证成功:

Authentication event AuthenticationSuccessEvent: user; details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null 
Authentication event InteractiveAuthenticationSuccessEvent: user; details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null 
但是,我被重定向回登录页面,而不是请求的资源。手动导航到资源仍然会使我重定向回登录页面

我的错误是显而易见的,还是我遗漏了什么?

我找到了解决办法

显然,应用程序配置中有一些配置选项以某种方式干扰了安全上下文会话

删除它们允许按预期进行身份验证