首页 > 编程知识 正文

spring security重定向,springsecurity自定义异常

时间:2023-05-06 11:07:41 阅读:157622 作者:4108

最近在使用springsecurity时,发生了以下问题

1、 anyRequest ().authenticated; http.forml ogin (.logi npage (/log in.html ).loginprocessingurl/API/private/log in ).defaultsucccessuure我们这是

. anyRequest ().authenticated )意味着任何请求都需要登录认证,如果跳转到/login.html,则login.html也是请求,因此login.html

所以就造成了无限循环进行重定向。

http.forml ogin (.logi npage (/log in.html ).loginprocessingurl/API/private/log in ).defaultsucccessure.ant . and ().csrf ) ).disable ); 的. and ().csrf ) ).disable ); CRF (伪造跨网站请求)也可以理解为防火墙; 否则,健康耳机登录时,重定向次数不会太多,但会返回login.html页面

当然,也有其他情况下重定向次数过多,但本质上是访问login.html,让login.html进行认证,结果陷入访问死循环

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。