我目前正在研究存儲純明確密碼(...)的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