I have configured my Vaadin/Spring Boot application to redirect to a separate login page (located on its own UI) if the user is not logged in.
After the login, i want the user to be redirected back to the page he originally tried to access (e.g. by opening a bookmark).
In my WebSecurityConfigAdapter i use the SavedRequestAwareVaadinAuthenticationSuccessHandler. This has two problems however:
-
query parameters are not restored. For example, the user tries to go to http://localhost:9002/content#!/news.
He will be redirected to http://localhost:9002/login#!/news.
After the successful redirect, he is redirected to http://localhost:9002/content#!/ when he should be redirected to http://localhost:9002/content#!/news. -
If the user access the login page directly, http://localhost:9002/login, i want him to be redirected to http://localhost:9002/content
@Bean(name = VaadinSharedSecurityConfiguration.VAADIN_AUTHENTICATION_SUCCESS_HANDLER_BEAN)
VaadinAuthenticationSuccessHandler vaadinAuthenticationSuccessHandler(HttpService httpService,
VaadinRedirectStrategy vaadinRedirectStrategy) {
SavedRequestAwareVaadinAuthenticationSuccessHandler successHandler = new SavedRequestAwareVaadinAuthenticationSuccessHandler(
httpService, vaadinRedirectStrategy, "/");
return successHandler;
}