【发布时间】:2019-10-14 20:50:15
【问题描述】:
这是我的注销代码。它被重定向到logout.done,但是,如果我再次转到hello,我仍然可以访问它。
public void configure(HttpSecurity http) throws Exception {
http.httpBasic().and().authorizeRequests().anyRequest().authenticated().antMatchers(HttpMethod.GET, "/hello/**").hasRole("user")
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/logout.done").deleteCookies("JSESSIONID")
.invalidateHttpSession(true);
}
这里有什么问题?
【问题讨论】:
-
您是否尝试添加
clearAuthentication(true)?在.logout()之后可以像..logout().clearAuthentication(true)..一样添加它 -
基本身份验证和注销不起作用。一旦您注销,您将再次登录,因为客户端可能会再次发送基本标头。如果您使用的是 js 客户端,请确保在客户端上也保留基本身份验证标头。