Change redirect behaviour for certain endpoints


I have a question which I’m hoping I can express clearly! We’ve just started integrating OKTA with our application (Spring Boot + React) we’ve followed the Java setup instructions and created a “Web” app in OKTA (annotated our app with the @EnableOAuth2Sso). So far everything’s working well, if we hit our app and we’re redirected to the login page, sign in, redirected back to app.

What we’re now trying to work out is how to stop this behaviour for certain endpoints, i.e. if we hit a service API endpoint directly (rather than through our React UI) and we’re currently not signed in, we want to receive a 403 status rather than be redirected to the login page (but if we were logged in, we would receive the data as normal).

Is this possible?

Many thanks in advance!

Hey @Djbbarnes!
Take a look Http403ForbiddenEntryPoint. You would need to configure an EntryPoint similar to this post:

Keep us posted!

1 Like

Perfect! Worked like a charm! Thank you very much for the help!

1 Like