You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a @PreAuthorize annotated method is called with insufficient permissions (anonymous call, missing authorities, missing roles), a AuthorizationDeniedException is thrown (like with Spring 6) but it is translated into HTTP 500 response.
With Spring 6 the response status is 401 or 403 with WWW-Authenticate header. Writing a @ExceptionHandler for this exception is possible but error prone.
When endpoints are secured by request matchers in the SecurityFilterChain configuration the status is 401 or 403 with WWW-Authenticate header.