I am on Grails 2.1.1 and Spring Security Core Plugin 1.2.7.3.
I am trying to assign Roles to Users in BootStrap.groovy and persist these assignments. I create my Roles and an Admin User in BootStrap.
I found the following blog post: Create User Roles for Spring Security
When I try this approach, I get:
2012-09-16 22:00:56,762 ERROR [org.codehaus.groovy.grails.web.context.GrailsContextLoader] Error executing bootstraps:
groovy.lang.MissingMethodException: No signature of method: User.addToAuthorities() is applicable for argument types: (Role) values: Possible solutions: getAuthorities()
I also tried
class BootStrap {
def init = { servletContext ->
....
admin.getAuthorities().add(adminRole)
admin.save(flush: true)
....
}
}
However, when I checked the user_role table, it was empty (I checked and entries for Admin User and Admin Role were in respective user and role tables, just not the association).
Could anyone please provide me some guidance or insight on what I am doing wrong? Thank you very much.