设为首页 加入收藏

TOP

从SpringBoot 2.6.0升级到3.0.1之后,无法成功登录系统的问题及解决方法
2023-07-25 21:41:27 】 浏览:27
Tags:SpringBoot 2.6.0 3.0.1 之后 成功登 解决方

简单记录一下从SpringBoot 2.6.0升级到3.0.1之后,无法成功登录系统的问题。

目前的解决方法:
在SecurityConfiguration配置中添加 httpSecurity.securityContext().requireExplicitSave(false); ,然后就能正常登录了。

但是没法解释的是,直接使用系统中默认的UsernamePasswordFilter时,是不用添加这一句也能正常登录的。等过两天再研究吧。


相关的链接:
SwitchUserFilter not working in Spring Security 6
https://github.com/spring-projects/spring-security/issues/12504

After upgrade to spring boot 3.0.0-M5, TestingAuthenticationToken and UsernamePasswordAuthenticationToken not work the same as spring boot 2.7.3 #11977
https://github.com/spring-projects/spring-security/issues/11977

Spring security does not redirect to success login after authentication success #4479
https://github.com/spring-projects/spring-security/issues/4479


写给自己看的:

系统中有多个自定义的AuthenticationFilter和对应的自定义AuthenticationProvider。升级到3.0.1之后,无法成功登录。
Debug的时候,发现在自定义的AuthenticationProvider中是能成功返回authentication的,但是之后却不能成功重定向到首页。如下面链接中有提到的,认证信息被清除了。
后来又找到了几个相关的关键词 requireExplicitSave SecurityContextHolderFilter SecurityContextPersistenceFilter
之前是默认会自动存认证信息,现在需要显式存储。不过还是搞不清楚具体是什么意思。

测试项目中的几种情况:
1,自定义authentication provider,不用自定义的authentication filter,可以成功登录。
2,自定义authentication provider,用了自定义的authentication filter,不能成功登录。但是在配置中添加 httpSecurity.securityContext().requireExplicitSave(false) 之后,就能成功登录。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇学习笔记——Mybatis映射文件根标.. 下一篇JavaFx 页面和控件设置快捷键

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目