I have my Spring MVC & Spring Security up and running as suggested by Spring's own reference application "petclinic". Everything's fine except that the login does not persist a browser restart.
What has to be considered to make sure a logged in user does not need to relogin after browser restart?
To enable Spring Security integration with Spring MVC add the @EnableWebSecurity annotation to your configuration. Spring Security provides the configuration using Spring MVC's WebMvcConfigurer.
On a browser restart, user sessions aren't maintained. So, you login informations doesn't survive a browser restart because they are stored in session.
To set up a login that survives browser restarts, you need to implement a cookie based authentication, also known as "Remember me" in Spring security.
To set up "Remember me" using Spring security, I suggest you the following article. You can also check out Spring documentation on the subject.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With