Using Spring boot and Authorization Code Flow.
After the user successfully authenticates with Okta I want to customize where the user is redirected to. I am having trouble finding a way to customize this. Any thoughts?
If I secure the /login route, I would expect that I could set a controller get some response, but it looks like Spring Security never lets it come to my controller.
Doing some debugging I find that SavedRequestAwareAuthenticationSuccessHandler is the handler being used by default, which has my request saved in session. Is there a way to override this behavior?
IIRC the default login success handler saves the page that redirects you over to your login page. If you were to navigate to /login I think it would default to / but there is a method to change that.
To change this behavior you can set the SuccessHandler, take a look at:
The formLogin didn’t work. It looks like the formLogin is not paid attention to if you are using an IDP like Okta to handle the login.
To get around this I created a protected route /login-redirect that can do my redirection between different views based on the user role.
If there is a better solution I would love to know.