Can Spring Security use @PreAuthorize on Spring controllers methods?

egervari picture egervari · Jun 21, 2010 · Viewed 47.6k times · Source

Can Spring Security use @PreAuthorize on Spring controllers methods?

Answer

axtavt picture axtavt · Jun 21, 2010

Yes, it works fine.

You need <security:global-method-security pre-post-annotations="enabled" /> in ...-servlet.xml. It also requires CGLIB proxies, so either your controllers shouldn't have interfaces, or you should use proxy-target-class = true.