【问题标题】:Updating spring security user's password field?更新弹簧安全用户的密码字段?
【发布时间】:2012-04-21 08:37:59
【问题描述】:

我在更新 User 类的密码字段时遇到问题,我在 grails 中使用 SpringSecurity 插件,看到它应该像这样完成但不起作用...

user.password = springSecurityService.encodePassword(
                params.password, userInstance.username)

也试过了

user.password = springSecurityService.encodePassword(
                params.password)

有什么想法吗?

【问题讨论】:

    标签: grails spring-security


    【解决方案1】:

    如果您使用的是更新版本的插件(1.2.7 或更高版本),那么您不希望像您正在做的那样明确编码密码,因为 User 类中生成的代码会为您完成.如果您的域类没有,请仅调用springSecurityService.encodePassword,否则您将双重编码并且无法登录。

    如果您自己对密码进行编码,那么您显示的第一个版本使用用户名作为盐,而第二个版本没有盐。加盐密码是一个好主意,但不是必需的 - 您可以在文档第 12.2 节 - http://grails-plugins.github.com/grails-spring-security-core/docs/manual/

    中阅读它

    【讨论】:

    • 这就是问题所在,我使用的是 1.2.7,而用户已经在进行该编码。
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 2011-04-21
      • 1970-01-01
      • 2016-10-25
      • 2023-01-03
      • 1970-01-01
      • 2018-09-08
      相关资源
      最近更新 更多