您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Spring Boot中实现``注销''功能

在Spring Boot中实现``注销''功能

迟到总比没有好。Spring Boot为您认了许多安全组件,包括CSRF保护。要做的事情之一是强制POST注销,请参阅此处:http ://docs.spring.io/spring- security/site/docs/3.2.4.RELEASE/reference/htmlsingle/#csrf- logout

如此一来,您可以使用以下方式覆盖此内容

http.authorizeRequests()
.antMatchers("/admin/**").hasRole("ADMIN")                                      
.anyRequest().fullyAuthenticated()
.and()
.formLogin().loginPage("/login").failureUrl("/login?error").permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login");

最后一行很重要。

Java 2022/1/1 18:15:37 有433人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶