We have a spring-boot application that uses WebSecurityConfigurerAdapter.configure() to handle form login via
http.formLogin().loginPage("/login")
When the browser hits any GET mappings (/ typically) it redirects to the login page and creates a session in the database - we are using spring session jdbc.
We want to try to prevent this until the user is successfully logs in.
We have tried disabling session for root via
http.antMatcher("/").sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); // or NEVER
However a session is required once logged in so this produces other issues.
Is there any configuration that can delay session creation until the user successfully logs in?