I have 2 user roles - user and admin , if I go to a url where any authentication is needed and I am not authenticated - I get redirected to the login page, which is fine.

However, if I am logged in as user, and I try to access an admin only page, I get the home page displayed, but the url stays the same. I want to actually redirect to the home page rather than just display it.

...
.and()
    .exceptionHandling()
          .accessDeniedPage("/")

So is there any way to make the accessDeniedPage method redirect, because as I said the home page is displayed but the url does not change.

1 Answers

0
ScanQR On

May be try following?

.and()
    .exceptionHandling()
          .accessDeniedPage("redirect:/")