Rails Devise:身份验证时不检查密码盐
我正在使用 Devise 作为身份验证方法将 PHP 站点迁移到 Rails。旧站点使用 md5(盐 + 密码)来验证用户身份,因此我编写了一个自定义 Devise 加密器,如下所示:
module Devise
module Encryptors
class Md5 < Base
def self.digest(password, stretches, pepper)
Digest::MD5.hexdigest(password + 'the_salt_value')
end
end
end
end
当我使用密码“password”在新站点上创建新用户时,散列密码与旧站点上的用户相匹配密码为“password”,这很好。但是,password_salt 列中的值(我不清楚其用途)是不同的,当我迁移数据库时,旧站点上的用户无法使用“密码”登录。
处理这个问题的最佳方法是什么?有没有办法让 Devise 在身份验证时简单地比较 crypto_password 列中的值?
I'm migrating a PHP site over to Rails using Devise as the authentication method. The old site uses md5(salt + password) to authenticate users so I wrote a custom Devise encryptor as such:
module Devise
module Encryptors
class Md5 < Base
def self.digest(password, stretches, pepper)
Digest::MD5.hexdigest(password + 'the_salt_value')
end
end
end
end
When I create a new user on the new site with the password "password", the hashed password matches the user on the old site with the password "password", which is good. However, the values in the password_salt column, whose purpose I'm unclear on, are different and the user on the old site can't login with "password" when I migrate the database over.
What's the best way to deal with this problem? Is there a way to make Devise simply compare the values in the encrypted_password column when authenticating?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论