我目前正在研究存储纯明确密码(...)的Rails应用程序。因此,我正在使用“标准”SHA512加密迁移到Authlogic身份验证。从明确的密码存储迁移到authlogic
我这样做的正常工作:
#file /models/user.rb
class User < ActiveRecord::Base
acts_as_authentic { |c|
c.transition_from_crypto_providers = [MyOwnNoCrypto, Authlogic::CryptoProviders::Sha512]
}
end
#file /lib/my_own_no_crypto.rb
class MyOwnNoCrypto
def self.encrypt(*tokens)
return tokens[0] # or tokens.join I guess
end
def self.matches?(crypted_password, *tokens)
return crypted_password == tokens.join
end
end
这是很好的 - 和工作得很好 - 但我不知道是否有做一个性感的方式,也许有Authlogic核心选项?
谢谢!
哇!超好!非常感谢。 – 2010-06-21 10:00:40