2009-04-26 65 views
1

我使用acegi 0.5.1将我的grails 1.0.4 + acegi 0.4.1项目升级到grails 1.1。Grails Acegi插件springsecurity.GrailsDaoImpl - 用户[admin]没有GrantedAuthority

我能够无误地启动我的应用程序,但是当我想登录时,我收到“错误的用户名或密码”消息。 Grails的壳输出为:

2009-04-26 12:38:46997 [403984690 @ qtp0-0] ERROR springsecurity.GrailsDaoImpl - 用户
[管理员]无的GrantedAuthority

也许有人知道我为什么不能登录?用户“admin”在Bootstrap中创建。

我希望你能帮助我! 来自德国的感谢, whitenexx

回答

0

我发现我的问题。我必须自己编辑/编码passwordEncoder()或encodePassword()方法(使用我的算法等)。 passwordEncoder()已弃用,请使用encodePassword()!

1

我遇到了完全相同的问题。请检查以确保在BootStrap.groovy中创建用户时,您首先使用密码和所有字段创建用户,即使它们是可选的(不知道为什么)。然后创建新的角色,然后将该角色添加到该角色。

检查用户是否分配给角色的一种方法是查看将用户映射到角色的role_people表。

这是我BootStrap.groovy中的文件:

class BootStrap { 
    // include this line to encode password for ACEGI 
    def authenticateService 

    def init = { servletContext -> 
     //create admin user 
     def password = authenticateService.passwordEncoder("password") 
     def superadmin = new User(username:"admin",userRealName:"Administrator",passwd:password,enabled:true,emailShow:true,description:"admin user",email:"put email here").save() 

     //create admin role 
     def sudo = new Role(authority:"ROLE_ADMIN",description:"Site Administrator") 
     // now add the User to the role 
     sudo.addToPeople(superadmin) 
     sudo.save() 

     new Role(authority:"ROLE_USER",description:"User").save() 

    } 
    def destroy = { 
    } 
} 
+0

我发现我的问题。我必须自己编辑/编码passwordEncoder()或encodePassword()方法(使用我的算法等)。 passwordEncoder()已弃用,请使用encodePassword()! – whitenexx 2009-05-03 21:37:32

0

我曾使用acegi并有类似的问题。如果您使用acegi的编码默认值,请致电passwordEncoder()。否则,您应该致电encodePassword()