Yesterday I started updating our Grails application from the Acegi 0.5.2 plugin to the Spring security plugin. I am facing a few problems, maybe someone can help here?
After making the necessary changes (as described by Burt Beckwith on Migrating from the Acegi plugin ), I was able to run the Grails application again (Woohoo!). However, the login did not work anymore.
Our situation is this: we use our Grails application for our application logic. Authentication is performed using a username and password through web services. As the backend, we use the application database (dao) and LDAP. At the moment, we have disabled LDAP to simplify testing.
This is the code that performs authentication:
def authenticate(String username, String password) {
try {
println "Trying authentication with user " + username + " and password " + password + "."
def tempToken = new UsernamePasswordAuthenticationToken(username, password)
println "Temptoken is " + tempToken
def token = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))
println "Authentication token received was: " + token
} catch (AuthenticationException authenticationException) {
return false
}
return true
}
:
Trying authentication with user admin and password admin.
Temptoken is org.springframework.security.providers.UsernamePasswordAuthenticationToken@1f: Principal: admin; Password: [PROTECTED]; Authenticated: false; Details: null; Not granted any authorities
.
. , , . "--", .
:
class Authority {
static hasMany = [people: Person]
String description
String authority = ''
String authorityType
static constraints = {
authority(help:'x',class:'wide',blank: false,unique:true)
description(help:'x',class:'extrawide')
authorityType(help:'x',class:'wide')
people(help:'x',selectSort:'username',display:false)
}
String toString() {
return authority;
}
}
Person:
class Person {
static hasMany = [authorities: Authority]
static belongsTo = Authority
String username
String userRealName
String familyName
String givenName
String passwd
boolean enabled
String email
boolean emailShow
String description = ''
static constraints = {
username(blank: false, unique: true,help:'x',class:'wide')
userRealName(blank: false,help:'x',class:'wide')
familyName(blank: false,help:'x',class:'wide')
givenName(blank: false,help:'x',class:'wide')
email(help:'x',class:'wide')
emailShow(help:'x')
enabled(help:'x')
passwd(blank: false,password:true,show:false,help:'x',class:'wide')
authorities(nullable:true,help:'x',sortable:true,selectSort:'authority')
}
String toString() {
return username;
}
}
Config.Groovy :
security {
active = false
cacheUsers = false
grails.plugins.springsecurity.providerNames = ['daoAuthenticationProvider', 'anonymousAuthenticationProvider', 'rememberMeAuthenticationProvider']
grails.plugins.springsecurity.userLookUp.userDomainClassName = "Person"
grails.plugins.springsecurity.authority.className = "Authority"
, ( "" Acegi).
, LDAP . WireShark , LDAP. , - Authenticate, SpringSecurity , .
!