【问题标题】:Grails Acegi Plugin springsecurity.GrailsDaoImpl - User [admin] has no GrantedAuthorityGrails Acegi 插件 springsecurity.GrailsDaoImpl - 用户 [admin] 没有 GrantedAuthority
【发布时间】:2012-11-29 07:12:51
【问题描述】:

我将我的 grails 1.0.4 + acegi 0.4.1 项目升级到带有 acegi 0.5.1 的 grails 1.1。

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

2009-04-26 12:38:46,997 [403984690@qtp0-0] 错误 springsecurity.GrailsDaoImpl - 用户
[admin] 没有 GrantedAuthority

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

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

【问题讨论】:

    标签: grails groovy login spring-security


    【解决方案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 = {
         }
    } 
    

    【讨论】:

    • 我发现了我的问题。我必须自己编辑/编码 passwordEncoder() 或 encodePassword() 方法(使用我的算法等)。 passwordEncoder() 已弃用,请使用 encodePassword()!
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      我使用过 acegi 并且遇到了类似的问题。如果您使用 acegi 的默认编码,请致电 passwordEncoder()。否则,您应该致电encodePassword()

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2010-12-11
        • 2011-01-26
        • 2011-02-19
        • 2010-10-29
        • 2011-01-05
        • 2011-05-28
        • 1970-01-01
        • 2011-09-06
        相关资源
        最近更新 更多