OpenID + Acegi Plugin
As I’ve previously mentioned, I’m standardizing on OpenID as sole entry point to noisyheads. Using the Acegi Plugin, here’s the story so far..
The OpenID tutorial didn’t offer much (and I guess that’s all to it anyway). Generated my equivalent of User and Role authentication classes. From the tutorial, there was mention of removing the password though didn’t really mention how. Nonetheless, I removed everything in the generated User and ended up with this:
class User
{
static final String DEFAULT_ID = 'DEFAULT_ID'
static hasMany = [authorities: Role]
static belongsTo = Role
String identifier = DEFAULT_ID
boolean enabled = true
static constraints = {
identifier(blank: false, unique: true)
enabled()
}
}
Where ‘identifier’ is the userName counterpart. Also added a Null Object, which came in handy later on (on the next post perhaps 😉 ). Edited SecurityConfig.groovy and removed the ‘password’ property. Gave it a shot and obviously failed.
Pfft! Password property is nowhere to be found, me app says. Investigated, and saw that GrailsDaoImpl.groovy, which is the plugin’s implementation of the UserDetailsService so happens to expect a domain class with a password property. Pfft! Specifically located at method: loadUserByUsername(final String username, final boolean loadRoles) where it calls createUserDetails(). Easy enough, I have to create my own version then, which overcomes this issue. Though I would normally compose, I just extended this class just because I’m lazy (hey, prototyping mode) :-p Simply removed the invocation to ‘password’ property and instead passed a blank String. Placed this in src/groovy then edited Spring beans configuration to inject this instead (love the Groovy config version!). The bean id btw is ‘userDetailsService.’ And tried logging in with my Blogger account, and what do you know. It worked!
But then, I realized user registration would be a pain in the ass now…
Trackbacks