jwt
jwt copied to clipboard
when configuring the sessionManagement with "Stateless", and trying to login from the browser, the application redirect to the login page again
I trying to follow this article https://www.danvega.dev/blog/spring-security-jwt but the problem is that when I add the following configuration
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
return http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(
authConfig ->
authConfig.anyRequest().authenticated()
)
.sessionManagement(sessionManagementConfigurer -> sessionManagementConfigurer.sessionCreationPolicy(STATELESS))
.httpBasic(Customizer.withDefaults())
.formLogin(Customizer.withDefaults())
.build();
}
as in the article, and go the home url, the application redirects me to the login screen and after entering my credentials, the application redirects me again to the login page (I think this is because it's stateless so the session id will not recognized) when I removed the stateless config it works, so I want to mention that so that when any one will follow the article to know about that or to update the article with this note.
and also many thanks for providing such an article.