I am using the spring-security-core plugin in my grails app. I need to know the current user\'s role in a controller action. How can I retrieve that?
If you simply need to check to see if a user is in a specific role then use SpringSecurityUtils.ifAllGranted
which takes a single String as an argument which contains a comma-delimited list of roles. It will return true if the current user belongs to all of them. SpringSecurityUtils
also has methods like ifAnyGranted
, ifNotGranted
, etc, so it should work for whatever it is you are trying to accomplish.