secure-password 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/secure_password.rb +12 -2
- data/lib/secure_password/testing.rb +3 -0
- data/test/secure_password_test.rb +1 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2329db84355b9783f598d01dcb8bfbdf6a7b908c
|
4
|
+
data.tar.gz: c9e8b2a617d30d53e7f892cc6e37423237ec7836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc310db147d696aa7eeeab6cf237709f5658a047facab178c1af5ef2b5388249c09bafdebcabf6323a984af55893d2cca086093fbba07ad81925539d3a115362
|
7
|
+
data.tar.gz: 884ba8dbed565f78fad6020b3c2dd8362d9aaaf0822e0a8a26d3b54eb9b6c5e7cab2d66f71262e295cd89ebb23c8e06d75e8d67dd43413472a5a1255324c5508
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
secure-password
|
1
|
+
secure-password [](https://travis-ci.org/frodsan/secure-password)
|
2
2
|
===============
|
3
3
|
|
4
4
|
Set and authenticate against [bcrypt][bcrypt] passwords.
|
@@ -80,7 +80,7 @@ Bcrypt's cost factor
|
|
80
80
|
The default cost factor used by `BCrypt` is `10`. To change it, use:
|
81
81
|
|
82
82
|
```ruby
|
83
|
-
|
83
|
+
SecurePassword.cost = 12
|
84
84
|
```
|
85
85
|
|
86
86
|
Check ["Cost Factors"][cost-factors] section for more information.
|
@@ -93,7 +93,9 @@ However, tests don't need this security measures. To speed up your tests,
|
|
93
93
|
you can decrease the default cost factor to the minimum:
|
94
94
|
|
95
95
|
```ruby
|
96
|
-
|
96
|
+
require "secure_password/testing"
|
97
|
+
|
98
|
+
SecurePassword.cost # => 4
|
97
99
|
```
|
98
100
|
|
99
101
|
Contributing
|
data/lib/secure_password.rb
CHANGED
@@ -3,11 +3,21 @@
|
|
3
3
|
require "bcrypt"
|
4
4
|
|
5
5
|
module SecurePassword
|
6
|
+
@cost = nil
|
7
|
+
|
8
|
+
def self.cost
|
9
|
+
@cost || BCrypt::Engine.cost
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.cost=(cost)
|
13
|
+
@cost = cost
|
14
|
+
end
|
15
|
+
|
6
16
|
def authenticate(unencrypted)
|
7
17
|
BCrypt::Password.new(password_digest) == unencrypted
|
8
18
|
end
|
9
19
|
|
10
|
-
def password=(unencrypted)
|
11
|
-
self.password_digest = BCrypt::Password.create(unencrypted)
|
20
|
+
def password=(unencrypted, cost: SecurePassword.cost)
|
21
|
+
self.password_digest = BCrypt::Password.create(unencrypted, cost: cost)
|
12
22
|
end
|
13
23
|
end
|
@@ -5,6 +5,7 @@ require "minitest/autorun"
|
|
5
5
|
require "minitest/pride"
|
6
6
|
require "minitest/sugar"
|
7
7
|
require_relative "../lib/secure_password"
|
8
|
+
require_relative "../lib/secure_password/testing"
|
8
9
|
|
9
10
|
class User
|
10
11
|
include SecurePassword
|
@@ -12,8 +13,6 @@ class User
|
|
12
13
|
attr_accessor :password_digest
|
13
14
|
end
|
14
15
|
|
15
|
-
BCrypt::Engine.cost = BCrypt::Engine::MIN_COST
|
16
|
-
|
17
16
|
class SecurePasswordTest < Minitest::Test
|
18
17
|
test "sets hashed password" do
|
19
18
|
user = User.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secure-password
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- LICENSE
|
90
90
|
- README.md
|
91
91
|
- lib/secure_password.rb
|
92
|
+
- lib/secure_password/testing.rb
|
92
93
|
- test/secure_password_test.rb
|
93
94
|
homepage: https://github.com/frodsan/secure-password
|
94
95
|
licenses:
|