I have the following spring security configuration:
<security:http>
......
<security:intercept-url pattern="/auth/**" access="ROLE_ADMIN"/>
.........
</security:http>
I would like to log every case when “ROLE_ADMIN” user hits any of “/auth/**” URL pattern.
Can I put some kind of interceptor on this pattern?
I had to do the same thing. Use an
@Aspectwhich fires for every execution of a handler method in your/auth/controller. Annotate the class as a@Componentso its a Spring bean, add theAspectJ@Aspectannotation, and you can then inspect theJoinPointfor whatever the user is doing – method signature, objects, etc. Write whatever you find to an audit table.See http://static.springsource.org/spring/docs/current/reference/aop.html for full details. I would think a
@Beforeor@Afterwould work for your purposes.