Handling AccessDenied with Method Level Security

前端 未结 3 411
春和景丽
春和景丽 2021-01-05 03:29

i have a method secured with spring security as follows:

@PreAuthorize(\"hasRole(\'add_user\')\")
public void addUser(User user) ;

and if a

3条回答
  •  醉梦人生
    2021-01-05 03:55

    I have run into the same problem myself and posted another question relating to the same issue. After several hours of digging around, I finally found the solution for my issue. I know this question is 2+ years old, but thought I would update it with information in case it was of value to someone else.

    In a nutshell, I noticed that the SimpleMappingExceptionResolver was handling the exception and resolving it with a default mapping. Consequently, there was no exception left to bubble up the stack to the ExceptionTranslationFilter which would redirect to the access-denied-handler.

    Please see Spring Security ignoring access-denied-handler with Method Level Security for further information.

提交回复
热议问题