I am using Grails Spring Security Plugin 1.2.7.3 and would like to have the User authenticate via Email Address and Password. I would like Email Address to be the primary Login ID.
I came across the following Nabble post regarding case insensitive usernames, where the original poster is attempting to do the same. However, I was a bit confused on a few points:
-
I understand that I need to write my own implementation of
UserDetailsServiceand register it ingrails-app/conf/spring/resources.groovy.However, I wasn’t sure which folder the custom implementation of
UserDetailsServiceshould go (best practices). My guesses are either/grails-app/services,/grails-app/utils, or/src/groovy. Has anyone done this before and where is the best place for the customUserDetailsService?I read this chapter in the Docs: http://grails-plugins.github.com/grails-spring-security-core/docs/manual/guide/11%20Custom%20UserDetailsService.html but I didn’t really see guidance on what Grails folder to put it in.
-
I created my User domain class via s2 command:
s2-quickstart com.philiptenn.security User Role RequestmapIf I were to rename the field
User.usernametoUser.emailso that my code is clearer, will I be in for a world of hurt?I did a Find Usages on this field, and one stuck out in DefaultSecurityConfig.groovy:
userLookup.usernamePropertyName = 'username'Could I just update this to read:
DefaultSecurityConfig.groovy:userLookup.usernamePropertyName = 'email'
Thank you.
As you pointed out, you can override the default security configs in your own
Config.groovy, the options all start withgrails.plugins.springsecurity, so it would begrails.plugins.springsecurity.userLookup.usernamePropertyName = 'email'(docs). That’s the first thing I’d try. If you check out the source of the GormUserDetailsService, the default userDetailsService, you’ll see it uses that property for the lookup.