spring boot security 将您重定向的次数过多
在学习spring boot security的过程中遇到了这样的一个问题。
查看代码,为了跳转到我们自己定义的登录页面,写了loginPage("/login.html"),按照正常的逻辑,应该我们在访问接口的时候,都会跳到登录页面,结果却报错了。其原因是我们在访问接口时,因为有 anyRequest(),对所有的请求都要进行认证,所以会跳到login.html这个页面,跳转过去之后去请求login.html这个页面也需要身份认证,所以还是跳到了login.html这个页面,形成了死循环,所以会出现这个错误。
http.formLogin().loginPage("/login.html").and().authorizeRequests().anyRequest().authenticated();
解决方式:加上.antMatchers("/login.html").permitAll() ,在这个方法里添加的url是不需要进行身份认证的,如果以后有更多的页面需要加入,只需要以逗号隔开就行,如antMatchers("/login.html","/index.html").permitAll()
http.formLogin().loginPage("/login.html").and().authorizeRequests().antMatchers("/login.html").permitAll().anyRequest().authenticated();
spring boot security 将您重定向的次数过多相关推荐
- Spring Boot Security + Vue 登录成功后重定向无 Access-Control-Allow-Origin 问题解决办法
需要明确: 已正确配置跨域资源共享(CORS)(不然也不可能看到登录成功了). 已正确配置了跨站请求伪造(CSRF)(登录时需要携带 _csrf.token). 全部使用 POST 提交的数据. 本文 ...
- 《深入理解 Spring Cloud 与微服务构建》第十六章 Spring Boot Security 详解
<深入理解 Spring Cloud 与微服务构建>第十六章 Spring Boot Security 详解 文章目录 <深入理解 Spring Cloud 与微服务构建>第十 ...
- Spring Boot + Security + MyBatis + Thymeleaf + Activiti 快速开发平台项目
项目介绍 Spring Boot + Security + MyBatis + Thymeleaf + Activiti 快速开发平台 基于 Layui 的后台管理系统模板,扩展 Layui 原生 U ...
- spring boot security学习
spring boot security(一) 配置认证和授权 通过继承WebSecurityConfigurerAdapter,可以重写其认证和授权的逻辑. @Configuration @Enab ...
- boke练习: spring boot: security post数据时,要么关闭crst,要么添加隐藏域
spring boot: security post数据时,要么关闭crst,要么添加隐藏域 http.csrf().disable(); 或者: <input name="${_cs ...
- Spring Boot + Security + Thymeleaf + Activiti 快速开发平台项目
点击关注公众号,实用技术文章及时了解 项目介绍 Spring Boot + Security + MyBatis + Thymeleaf + Activiti 快速开发平台 基于 Layui 的后台管 ...
- Spring Boot Security - Remember Me示例
Spring Boot Security- Remember Me Example - Websparrowhttps://www.websparrow.org/spring/spring-boot- ...
- Spring Boot + Security + MyBatis + Thymeleaf + Activiti 快速开发平台
前言 项目介绍 Spring Boot + Security + MyBatis + Thymeleaf + Activiti 快速开发平台 基于Layui的后台管理系统模板,扩展Layui原生UI样 ...
- SpringBootAdmin集成Turbine、使用Spring Boot Security添加安全验证
SpringBootAdmin集成Turbine Hystrix Dashboard是一个监控熔断器状况的组件,而Turbine是一个可以聚合多个HystrixDashboard的组件.在Spring ...
最新文章
- 华为笔记本matebook13_为什么我不推荐华为Matebook 13给职场新人/小白?
- 查看网页js数据接口
- D3.tsv与D3.csv加载数据
- AJAX的安全性及AJAX安全隐患
- 高级浏览器-SRWare Iron 29.0.1600.0 版本发布
- MYSQL索引结构学习笔记
- android开机自动开启zram,低内存配置 | Android 开源项目 | Android Open Source Project...
- shell调用python权限不足_使用权限从python运行shell脚本
- LWIP之TCP协议
- 一个c++程序员一年前的生活笔记
- 打车应用上马快递业务靠谱吗?
- 域控服务器取消验证_Linux 开发笔记《使用CentOS 7进行初始服务器设置》
- pytorch---之halfTensor
- win11电脑快捷键
- centos7 aarch64 环境编译安装MP4Box
- 用计算机三角函数公式,三角函数公式习题.doc
- 做正确的事永远都不迟
- winstor磁盘阵列数据恢复
- 用piranha配置LVS
- NOI——Bless All
热门文章
- 食品类目如何打造爆款?
- windows 中文输入法卡死解决办法
- 估计参数的方法:最大似然估计、贝叶斯推断
- java9 钻石操作符
- pipenet.v9.0(Spray V3.40,Standard V3.4,Transient V5.3)
- HappyPack not work in webpack 4
- 私はずっと頑張って、しかしどうしてやはりこのようにしますか。自分で問題を探します!
- eclipse无法进入debug模式
- 能救命的Apple Watch和双卡双待的iPhone来了
- linux配置svn开启端口映射,linux 下搭建Subversion (SVN)