The plugin expects that there will be 4 booleans in the User class that control whether the user is enabled, locked, etc. If you don't need these, you can add transient fields with hard-coded values. You don't need a Role class or table - just a way to get the roles that are associated with each user.
So given a User class like this:
Code:
package com.yourcompany.yourapp
class User {
String username
String password
String authorities
}
you can make these changes:
Code:
package com.yourcompany.yourapp
import org.springframework.security.core.authority.GrantedAuthorityImpl
class User {
String username
String password
String authorities
boolean enabled = true
boolean accountExpired = false
boolean accountLocked = false
boolean passwordExpired = false
static transients = ['enabled', 'accountExpired', 'accountLocked', 'passwordExpired', 'roles']
static constraints = {
username blank: false, unique: true
password blank: false
}
Set<GrantedAuthorityImpl> getRoles() {
(authorities ?: '').split(',').collect { new GrantedAuthorityImpl(it.trim()) }
}
}
and you're almost there. Then you need to add two lines to grails-app/conf/Config.groovy:
Code:
grails.plugins.springsecurity.userLookup.userDomainClassName = 'com.yourcompany.yourapp.User'
grails.plugins.springsecurity.userLookup.authoritiesPropertyName = 'roles'