If you want to control the navigation flow after a successful authentication, you can do so by adding your own AuthenticationSuccessHandler.
Add the following attribute to your element which refers to the customAuthenticationHandler bean,
...
The CustomAuthenticationHandler class looks like this:
public class CustomAuthenticationHandler extends SimpleUrlAuthenticationSuccessHandler{
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
String userTargetUrl = "/welcome.xhtml";
String adminTargetUrl = "/admin/welcome.xhtml";
Set roles = AuthorityUtils.authorityListToSet(authentication.getAuthorities());
if (roles.contains("ROLE_ADMIN")) {
getRedirectStrategy().sendRedirect(request, response, adminTargetUrl);
}
else if(roles.contains("ROLE_USER")) {
getRedirectStrategy().sendRedirect(request, response, userTargetUrl);
}
else {
super.onAuthenticationSuccess(request, response, authentication);
return;
}
}
}