I’m using the annotations provided by the Spring Security (AKA Acegi) plugin. I have controller actions annotated with
@Secured(['ROLE_ADMIN', 'ROLE_USER'])
To indicate that they should be available to administrators and regular users. But now I need to indicate that an action is available to administrators and unregistered users. Is it possible to use annotations to indicate a user without any role, i.e. unregistered?
Thanks,
Don
Here’s a solution that requires that you not be logged in, or that you have ROLE_ADMIN. You need a custom voter that processes a new ‘IS_NOT_AUTHENTICATED’ token:
Register this as a bean in resources.groovy:
and add it to the voters list in SecurityConfig.groovy by setting the ‘decisionVoterNames’ property:
and annotate your controller action with this:
and it’ll only allow non-authenticated users and authenticated users with ROLE_ADMIN.