Spring 当我调用logout时,它会更改jsessionid,但仍然允许我访问其他路径,而无需登录

Spring 当我调用logout时,它会更改jsessionid,但仍然允许我访问其他路径,而无需登录,spring,security,logout,Spring,Security,Logout,我正在尝试使用Spring安全性注销,但每当我调用注销url时,它都会更改jsessionid,但我仍然可以访问应该限制的url,并要求我重新登录 public void configure(HttpSecurity httpSecurity) throws Exception{ httpSecurity.httpBasic(); httpSecurity.authorizeRequests() .mvcMatchers(Htt

我正在尝试使用Spring安全性注销,但每当我调用注销url时,它都会更改jsessionid,但我仍然可以访问应该限制的url,并要求我重新登录

public void configure(HttpSecurity httpSecurity) throws Exception{

        httpSecurity.httpBasic();

        httpSecurity.authorizeRequests()
                .mvcMatchers(HttpMethod.GET, "/privateEvent").hasAuthority("REGISTERED_USER")
                .mvcMatchers(HttpMethod.DELETE, "/privateEvent/*").hasAuthority("RSVP_ADMIN")
                .mvcMatchers("/registerPrivateEvent").hasAuthority("REGISTERED_USER")
                .mvcMatchers("/guestList").hasAuthority("EVENT_PUBLISHER")
                .mvcMatchers("/eventPublishersList").hasAuthority("RSVP_ADMIN")
                .anyRequest().permitAll()
         .and()
                .logout()
                .invalidateHttpSession(true)
                .deleteCookies("JSESSIONID")
                .deleteCookies("XSRF-TOKEN")
                .clearAuthentication(true)
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                .logoutSuccessUrl("/allDone")
                .permitAll()
          .and()
                .csrf().disable();
}

看起来您丢失了。已验证()。试试这个-.anyRequest().authenticated()。我在第一个.and()之前添加了.anyRequest().authenticated(),但它仍然会给我同样的问题。也发布你的注销控制器方法。基本的验证和注销不起作用。登录一次后,每个请求将包括基本身份验证标头。基本上,您是在注销后登录的。如果您在浏览器中使用javascript解决方案,请清除其中的标题,如果您依赖浏览器,则基本上无法注销。