Skip to content

Instantly share code, notes, and snippets.

@tadasy
Created April 19, 2011 12:43
Show Gist options
  • Save tadasy/927402 to your computer and use it in GitHub Desktop.
Save tadasy/927402 to your computer and use it in GitHub Desktop.
restful-authentication/lib/authentication/by_password.rb
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