Grails Spring Security Plugin setting up anonymous access with config type annotation

grails, spring-security

Solution

Found the answer. To be able to allow anonymous access to a controller or controller method you just add:

@Secured(['IS_AUTHENTICATED_ANONYMOUSLY']) 
def method(){
}

or:

@Secured(['IS_AUTHENTICATED_ANONYMOUSLY']) 
class SomethingController{
}

Problem

According to the docs, when setting up controllers to be accessible by anybody, just leave then not annoatated by @Secured In my case if its not annotated, my requests always ends up being denied/403. ``` def show(User userInstance) { searchTargetUser() } ``` Its worth noting that, its working as expected when annotated with @Secured. ``` @Secured(['ROLE_ADMIN', 'ROLE_OWNER']) def show(User userInstance) { searchTargetUser() } ``` How do you allow a method to be accessible anonymously?

Original source