You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the problem, a request is executed by two different threads:
CustomAuthenticationProvider: Thread[http-nio-8080-exec-4,5,main] SecurityContextHolder has authentication
AuthorizationFilter: Thread[http-nio-8080-exec-2,5,main] SecurityContextHolder authentication is null
These two threads are on the same level, there is no hierarchical relationship, so the InheritableThreadLocalSecurityContextHolderStrategy is also the same as the ThreadLocalSecurityContextHolderStrategy, also gets null in AuthorizationFilter as well.
Rightfully so, it goes to ExceptionTranslationFilter and the login fails
There was no such problem in spring 5, but now I can't achieve any login.
The text was updated successfully, but these errors were encountered:
In the process of upgrading from spring 5 to 6, I didn't change the logical code or set different configuration values, I just followed the changes in spring 6 and changed the way it was called, like .csrf().disable() => .csrf(CsrfConfigurer::disable)
But before I upgraded spring6, there was SecurityContextHolder automatically, no need to manually write SecurityContextHolder.getContextHolderStrategy().setContext(securityContext);, now I have to set these up manually
like #13866, But there seems to be a difference.
WebSecurityConfig:
customAuthenticationProvider:
I'm debugging here to get the thread name
I continued to debug backwards (making sure it was the same HTTP request), Reach this class: org.springframework.security.web.access.intercept.AuthorizationFilter:
Here is the problem, a request is executed by two different threads:
These two threads are on the same level, there is no hierarchical relationship, so the InheritableThreadLocalSecurityContextHolderStrategy is also the same as the ThreadLocalSecurityContextHolderStrategy, also gets null in AuthorizationFilter as well.
Rightfully so, it goes to ExceptionTranslationFilter and the login fails
There was no such problem in spring 5, but now I can't achieve any login.
The text was updated successfully, but these errors were encountered: