Created
April 19, 2011 12:43
-
-
Save tadasy/927402 to your computer and use it in GitHub Desktop.
restful-authentication/lib/authentication/by_password.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ModelClassMethods | |
# This provides a modest increased defense against a dictionary attack if | |
# your db were ever compromised, but will invalidate existing passwords. | |
# See the README and the file config/initializers/site_keys.rb | |
# | |
# It may not be obvious, but if you set REST_AUTH_SITE_KEY to nil and | |
# REST_AUTH_DIGEST_STRETCHES to 1 you'll have backwards compatibility with | |
# older versions of restful-authentication. | |
def password_digest(password, salt) | |
digest = REST_AUTH_SITE_KEY | |
REST_AUTH_DIGEST_STRETCHES.times do | |
digest = secure_digest(digest, salt, password, REST_AUTH_SITE_KEY) | |
end | |
digest | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment