Grails with SpringSecurity, check if the current user can access controller / action
grails, spring-security
Solution
To check roles in view : Spring security plugin provides ifAllGranted, ifAnyGranted, ifNoneGranted etc., tags to check roles
For example, to check Admin Role of logged in User :
<sec:ifLoggedIn>
<sec:ifAllGranted roles="ROLE_ADMIN">
Admin resource
</sec:ifAllGranted>
</sec:ifLoggedIn>
(tested in grails-2.2.2 and springSecurityCorePlugin-1.2.7.3)
Problem
I'm currently developing a menu for my application that should be able to display only the controllers that the current user can access (requestmap defined in the database). How can I check if the current user has access to a specific controller and action?