1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Also pass stretches to salt generation.

This commit is contained in:
José Valim 2010-07-12 06:59:49 +02:00
parent eca511a8f2
commit a87bc4a861
5 changed files with 10 additions and 94 deletions

View file

@ -8,12 +8,6 @@ GIT
mongo (~> 1.0.3)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
mongoid (2.0.0.beta9)
activemodel (~> 3.0.0.beta)
bson (~> 1.0.3)
mongo (~> 1.0.3)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
PATH
remote: /Users/jose/Work/github/rails
@ -21,18 +15,6 @@ PATH
actionmailer (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
mail (~> 2.2.3)
actionmailer (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
mail (~> 2.2.3)
actionpack (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
rack (~> 1.2.1)
rack-test (~> 0.5.4)
tzinfo (~> 0.3.16)
actionpack (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
@ -46,15 +28,6 @@ PATH
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activemodel (3.0.0.beta4)
activesupport (= 3.0.0.beta4)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
arel (~> 0.4.0)
tzinfo (~> 0.3.16)
activerecord (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
@ -63,10 +36,6 @@ PATH
activeresource (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
activeresource (3.0.0.beta4)
activemodel (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
activesupport (3.0.0.beta4)
activesupport (3.0.0.beta4)
rails (3.0.0.beta4)
actionmailer (= 3.0.0.beta4)
@ -76,19 +45,6 @@ PATH
activesupport (= 3.0.0.beta4)
bundler (>= 1.0.0.beta.2)
railties (= 3.0.0.beta4)
rails (3.0.0.beta4)
actionmailer (= 3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activerecord (= 3.0.0.beta4)
activeresource (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
bundler (>= 1.0.0.beta.2)
railties (= 3.0.0.beta4)
railties (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
rake (>= 0.8.3)
thor (~> 0.13.7)
railties (3.0.0.beta4)
actionpack (= 3.0.0.beta4)
activesupport (= 3.0.0.beta4)
@ -99,92 +55,48 @@ GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
abstract (1.0.0)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
bcrypt-ruby (2.1.2)
bcrypt-ruby (2.1.2)
bson (1.0.3)
bson (1.0.3)
bson_ext (1.0.1)
bson_ext (1.0.1)
builder (2.1.2)
builder (2.1.2)
columnize (0.3.1)
columnize (0.3.1)
erubis (2.6.6)
abstract (>= 1.0.0)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.1)
i18n (0.4.1)
linecache (0.43)
linecache (0.43)
mail (2.2.5)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mail (2.2.5)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
mime-types (1.16)
mocha (0.9.8)
rake
mocha (0.9.8)
rake
mongo (1.0.3)
bson (= 1.0.3)
mongo (1.0.3)
bson (= 1.0.3)
nokogiri (1.4.2)
nokogiri (1.4.2)
polyglot (0.3.1)
polyglot (0.3.1)
rack (1.2.1)
rack (1.2.1)
rack-test (0.5.4)
rack (>= 1.0)
rack-test (0.5.4)
rack (>= 1.0)
rake (0.8.7)
rake (0.8.7)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug (0.10.3)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
sqlite3-ruby (1.3.0)
sqlite3-ruby (1.3.0)
thor (0.13.7)
sqlite3-ruby (1.3.1)
thor (0.13.7)
treetop (1.4.8)
polyglot (>= 0.3.1)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.22)
tzinfo (0.3.22)
warden (0.10.7)
rack (>= 1.0.0)
warden (0.10.7)
rack (>= 1.0.0)
webrat (0.7.0)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
webrat (0.7.0)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.pre)
will_paginate (3.0.pre)
PLATFORMS

View file

@ -12,7 +12,7 @@ module Devise
raise NotImplemented
end
def self.salt
def self.salt(stretches)
Devise.friendly_token
end
end

View file

@ -11,8 +11,8 @@ module Devise
::BCrypt::Engine.hash_secret([password, pepper].join, salt, stretches)
end
def self.salt
::BCrypt::Engine.generate_salt
def self.salt(stretches)
::BCrypt::Engine.generate_salt(stretches)
end
end
end

View file

@ -37,7 +37,7 @@ module Devise
@password = new_password
if @password.present?
self.password_salt = self.class.encryptor_class.salt
self.password_salt = self.class.password_salt
self.encrypted_password = password_digest(@password)
end
end
@ -93,6 +93,10 @@ module Devise
@encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)
end
def password_salt
self.encryptor_class.salt(self.stretches)
end
# We assume this method already gets the sanitized values from the
# DatabaseAuthenticatable strategy. If you are using this method on
# your own, be sure to sanitize the conditions hash to only include

View file

@ -23,7 +23,7 @@ class Encryptors < ActiveSupport::TestCase
test "should have length #{value} for #{key.inspect}" do
swap Devise, :encryptor => key do
encryptor = Devise::Encryptors.const_get(key.to_s.classify)
assert_equal value, encryptor.digest('a', 4, encryptor.salt, nil).size
assert_equal value, encryptor.digest('a', 4, encryptor.salt(4), nil).size
end
end
end