I´m using Pac4j, Shiro and Keycloak as Auth Provider.
Sometimes the user get a URL and would like to open this URL in my app, but he will be redirected to the login page. Afterwards he should be redirected to the initial requested URL and not the default startpage
For example:
- User get URL: http://myapplication.com/portal/userList.jsf
- User will be redirect to http://myapplication.com/login.jsf
- User will enter his credentials for authentication
- User will be redirect to http://myapplication.com/portal/userList.jsf and NOT e.g. default startpage) http://myapplication.com/portal/dashboard.jsf
Before I have used the Form Authentication and call a function in the backend.
In this function I was using the code to get the URL which was initial requested:
final SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(Faces.getRequest());
Faces is from import org.omnifaces.util.Faces;
How can I do this with Pac4j ?
If the originally requested URL is protected, it is saved by pac4j and restored after a successful form authentication.
It really depends on your configuration here. Turn on DEBUG logs on the
org.pac4j.core.enginepackage to see what URL is restored by theDefaultSavedRequestHandler.