Acegi on Grails and plugin ponderance
November 14, 2008
There’s a few little pain points I just encountered setting up Acegi on Grails. I appreciate the ‘grails generate-manager’ functionality, and the ‘grails generate-registration’ stuff as well, and the basic tutorial is a good start. Unfortunately, they still left off the part about having to define a role (using the role controller, for example) before the self-registration works. Specifically, you’ll need to define a ‘ROLE_USER’ in the Role controller to match the defaultRole in the security{} block in the SecurityConfig.groovy file.
I just added
def r1 = new Role(authority:”ROLE_USER”, description:”User”).save()
def r2 = new Role(authority:”ROLE_ADMIN”, description:”Admin”).save()
in my BootStrap.groovy file and this gets me going.
On a related note about Grails plugins, I’m already concerned about directive name clashes. When a plugin is registered, it can expose extra functionality to the grails command line user. In the above example, the Acegi plugin also gives you “grails generate-manager”, “grails generate-registration”, among others. Those names are pretty generic – no other Grails plugin can really depend on being able to use the term ‘generate-manager’ because it’ll conflict with the Acegi plugin should it also be installed.
I’d think it would make more sense to have a convention whereby all plugins’ functionality was prefixed by the plugin name, so the above would be “grails acegi-generate-manager”, for example.










Posted in 

Entrepreneur, developer, writer, podcaster, teacher, ex-bassist.




November 14th, 2008 at 11:53 pm
The docs on the wiki are publicly editable. Or you could write up a feature request at http://jira.codehaus.org/browse/GRAILSPLUGINS under grails-acegi.
November 21st, 2008 at 3:06 pm
Actually other Grails plugins can use those names. If Grails finds multiple scripts that match the name “generate-manager” it will give you a choice of which one to run.