springspring-securityannotationsauthorizationspring-annotations

How to debug Spring Security authorization annotations?


I have spring security application in which want to enable annotations security (pre and post authorization). I also have small sample application in which i have implemented it already. Everything works. But moving configs to main applications failed. There is no errors in console. But annotations do not work. It seems, they are not readed at all. All configuration and component versions are completely the same.

There are

<security:global-method-security secured-annotations="enabled" /> 

records in security-context and servlet-context. But neither @Controller methods no @Service methods are secured with annotation in main application.

How can i debug it?

Solved!

After switch from < global-method-security secured-annotations="enabled" /> to pre/post annotations works fine.


Solution

  • Set the log level of org.springframework.security to debug. On invoking the method with annotations, you can find log messages that indicate interceptor being applied, especially look for: DEBUG MethodSecurityInterceptor

    Updated: That means there is some config difference between your sample app and main app Some pointers to look for: