'Redirect to /error instead of /oauth2/authorize with new spring-security-oauth2-autorization-server

I am using react client and new spring-security-oauth2-autorization-server. And I've configured public-client as was suggested in this video . At my local machine after entering login and password everything is ok auth server redirects me to /oauth2/authorize and then back to react app with code. But at testing environment (in my case it is Kubernetes with two containers) auth server redirects on /error?client_id=public-client&redirect_uri=.... I enabled TRACE all application but logs don't answer me where is the problem. Here is part of the log.

20220513 14:26:58 DEBUG o.s.s.a.d.DaoAuthenticationProvider:199 - Authenticated user
20220513 14:26:58 TRACE o.s.b.f.s.DefaultListableBeanFactory:264 - Returning cached instance of singleton bean 'delegatingApplicationListener'
20220513 14:26:58 TRACE o.s.s.w.a.s.CompositeSessionAuthenticationStrategy:79 - Preparing session with ChangeSessionIdAuthenticationStrategy (1/2)
20220513 14:26:58 DEBUG o.s.s.w.a.s.ChangeSessionIdAuthenticationStrategy:99 - Changed session id from F2238B1D17F13C607CC13DD00AD262DF
20220513 14:26:58 TRACE o.s.b.f.s.DefaultListableBeanFactory:264 - Returning cached instance of singleton bean 'delegatingApplicationListener'
20220513 14:26:58 TRACE o.s.s.w.a.s.CompositeSessionAuthenticationStrategy:79 - Preparing session with CsrfAuthenticationStrategy (2/2)
20220513 14:26:58 DEBUG o.s.s.w.c.CsrfAuthenticationStrategy:63 - Replaced CSRF Token
20220513 14:26:58 DEBUG o.s.s.w.a.UsernamePasswordAuthenticationFilter:318 - Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=org.springframework.security.core.userdetails.User [Username=Surkov, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, credentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[message_v, user_c]], Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=192.168.11.254, SessionId=F2238B1D17F13C607CC13DD00AD262DF], Granted Authorities=[message_v, user_c]]
20220513 14:26:58 TRACE o.s.b.f.s.DefaultListableBeanFactory:264 - Returning cached instance of singleton bean 'delegatingApplicationListener'
20220513 14:26:58 DEBUG o.s.s.web.DefaultRedirectStrategy:57 - Redirecting to https://192.168.25.55/auth/error?client_id=public-client&redirect_uri=https%3A%2F%2F192.168.25.55&response_type=code&scope=openid&state=0df5af37f09c46a7ae2f7cedca3991b4&code_challenge=LDBXhJi-uyu8rWgbneAqN19RQf7f5LJSwgJU3SCnrqg&code_challenge_method=S256&response_mode=query
20220513 14:26:58 DEBUG o.s.s.w.c.HttpSessionSecurityContextRepository:361 - Stored SecurityContextImpl [Authentication=UsernamePasswordAuthenticationToken [Principal=org.springframework.security.core.userdetails.User [Username=Surkov, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, credentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[message_v, user_c]], Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=192.168.11.254, SessionId=F2238B1D17F13C607CC13DD00AD262DF], Granted Authorities=[message_v, user_c]]] to HttpSession [org.apache.catalina.session.StandardSessionFacade@27cd0b2e]

Here we can see that Set SecurityContextHolder to UsernamePasswordAuthenticationToken with Authenticated=true but than it redirects to /error without any additional information about error.

BTW i use SameSate=None cookie and https at testing env.

JSESSIONID=4E559F0CCBE6258B590DD4809ECB3D3F; Path=/auth; HttpOnly; SameSite=None; Secure



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source