clearance 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a955d1866bf1879846034e89ca4f5a85cdf4602e67667e1ba93fae12ec5c832e
4
- data.tar.gz: 3e2c19f661f4910f0bf6c31a12dfae58b44c4a49283750e07ae28eb33ced6d17
3
+ metadata.gz: 1a6869cfdd76b965d10f6809fe4ad1639a57d242de11fd4a414ac017c515c94c
4
+ data.tar.gz: 759e38cd4bd2525c5f35ab53c1f994317d13f3e449248b2fdec521808b398346
5
5
  SHA512:
6
- metadata.gz: c8a2870d5567ae747cccbeda37a88fc6f31d5fca6cac57d2d2cbdb7016e22112f413c19a73b8f0edeb390b01ee04efe8da4633b69a2bd629bbfdfd2b6dbbbe5d
7
- data.tar.gz: ed611c62911b8ac335ae12fd6af9e4eeaa36b6541451ec2322b29a07820b6eb6d2ce3232262cc75d69697e2530e93746ee0089911e9b7ff39ee9ef64961fbe15
6
+ metadata.gz: fb078764b744a5763476b7e0098196b9cbafe21043943591e6a0deeeeee291fb3b745cdd3ce666f4fdce031dcf5602f3d7fab42424658c726f0da3a82bfecccd
7
+ data.tar.gz: 43108490f1763fbb0a46edfde7c13dbe09af98e29998345868e96b0d7d49e02ec9788a1147c78301563e8a26ae2b659200dd2864b9ff798ca8fba99833a1bf84
@@ -7,6 +7,7 @@ rvm:
7
7
  - 2.4.9
8
8
  - 2.5.7
9
9
  - 2.6.5
10
+ - 2.7.0
10
11
 
11
12
  gemfile:
12
13
  - gemfiles/rails_5.0.gemfile
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (2.1.0)
4
+ clearance (2.2.0)
5
5
  actionmailer (>= 5.0)
6
6
  activemodel (>= 5.0)
7
7
  activerecord (>= 5.0)
8
+ argon2 (~> 2.0, >= 2.0.2)
8
9
  bcrypt (>= 3.1.1)
9
10
  email_validator (~> 2.0)
10
11
  railties (>= 5.0)
@@ -12,52 +13,55 @@ PATH
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- actionmailer (6.0.2.1)
16
- actionpack (= 6.0.2.1)
17
- actionview (= 6.0.2.1)
18
- activejob (= 6.0.2.1)
16
+ actionmailer (6.0.3.2)
17
+ actionpack (= 6.0.3.2)
18
+ actionview (= 6.0.3.2)
19
+ activejob (= 6.0.3.2)
19
20
  mail (~> 2.5, >= 2.5.4)
20
21
  rails-dom-testing (~> 2.0)
21
- actionpack (6.0.2.1)
22
- actionview (= 6.0.2.1)
23
- activesupport (= 6.0.2.1)
22
+ actionpack (6.0.3.2)
23
+ actionview (= 6.0.3.2)
24
+ activesupport (= 6.0.3.2)
24
25
  rack (~> 2.0, >= 2.0.8)
25
26
  rack-test (>= 0.6.3)
26
27
  rails-dom-testing (~> 2.0)
27
28
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
28
- actionview (6.0.2.1)
29
- activesupport (= 6.0.2.1)
29
+ actionview (6.0.3.2)
30
+ activesupport (= 6.0.3.2)
30
31
  builder (~> 3.1)
31
32
  erubi (~> 1.4)
32
33
  rails-dom-testing (~> 2.0)
33
34
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
34
- activejob (6.0.2.1)
35
- activesupport (= 6.0.2.1)
35
+ activejob (6.0.3.2)
36
+ activesupport (= 6.0.3.2)
36
37
  globalid (>= 0.3.6)
37
- activemodel (6.0.2.1)
38
- activesupport (= 6.0.2.1)
39
- activerecord (6.0.2.1)
40
- activemodel (= 6.0.2.1)
41
- activesupport (= 6.0.2.1)
42
- activesupport (6.0.2.1)
38
+ activemodel (6.0.3.2)
39
+ activesupport (= 6.0.3.2)
40
+ activerecord (6.0.3.2)
41
+ activemodel (= 6.0.3.2)
42
+ activesupport (= 6.0.3.2)
43
+ activesupport (6.0.3.2)
43
44
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
45
  i18n (>= 0.7, < 2)
45
46
  minitest (~> 5.1)
46
47
  tzinfo (~> 1.1)
47
- zeitwerk (~> 2.2)
48
+ zeitwerk (~> 2.2, >= 2.2.2)
48
49
  addressable (2.6.0)
49
50
  public_suffix (>= 2.0.2, < 4.0)
50
51
  ammeter (1.1.4)
51
52
  activesupport (>= 3.0)
52
53
  railties (>= 3.0)
53
54
  rspec-rails (>= 2.2)
54
- appraisal (2.2.0)
55
+ appraisal (2.3.0)
55
56
  bundler
56
57
  rake
57
58
  thor (>= 0.14.0)
59
+ argon2 (2.0.2)
60
+ ffi (~> 1.9)
61
+ ffi-compiler (>= 0.1)
58
62
  bcrypt (3.1.13)
59
63
  builder (3.2.4)
60
- capybara (3.29.0)
64
+ capybara (3.33.0)
61
65
  addressable
62
66
  mini_mime (>= 0.1.3)
63
67
  nokogiri (~> 1.8)
@@ -65,39 +69,43 @@ GEM
65
69
  rack-test (>= 0.6.3)
66
70
  regexp_parser (~> 1.5)
67
71
  xpath (~> 3.2)
68
- coderay (1.1.2)
69
- concurrent-ruby (1.1.5)
70
- crass (1.0.5)
71
- database_cleaner (1.7.0)
72
- diff-lcs (1.3)
72
+ coderay (1.1.3)
73
+ concurrent-ruby (1.1.6)
74
+ crass (1.0.6)
75
+ database_cleaner (1.8.5)
76
+ diff-lcs (1.4.4)
73
77
  email_validator (2.0.1)
74
78
  activemodel
75
79
  erubi (1.9.0)
76
- factory_bot (5.1.1)
80
+ factory_bot (5.2.0)
77
81
  activesupport (>= 4.2.0)
78
- factory_bot_rails (5.1.1)
79
- factory_bot (~> 5.1.0)
82
+ factory_bot_rails (5.2.0)
83
+ factory_bot (~> 5.2.0)
80
84
  railties (>= 4.2.0)
85
+ ffi (1.13.1)
86
+ ffi-compiler (1.0.1)
87
+ ffi (>= 1.0.0)
88
+ rake
81
89
  globalid (0.4.2)
82
90
  activesupport (>= 4.2.0)
83
- i18n (1.7.0)
91
+ i18n (1.8.3)
84
92
  concurrent-ruby (~> 1.0)
85
- loofah (2.4.0)
93
+ loofah (2.6.0)
86
94
  crass (~> 1.0.2)
87
95
  nokogiri (>= 1.5.9)
88
96
  mail (2.7.1)
89
97
  mini_mime (>= 0.1.1)
90
- method_source (0.9.2)
98
+ method_source (1.0.0)
91
99
  mini_mime (1.0.2)
92
100
  mini_portile2 (2.4.0)
93
- minitest (5.13.0)
94
- nokogiri (1.10.7)
101
+ minitest (5.14.1)
102
+ nokogiri (1.10.10)
95
103
  mini_portile2 (~> 2.4.0)
96
- pry (0.12.2)
97
- coderay (~> 1.1.0)
98
- method_source (~> 0.9.0)
104
+ pry (0.13.1)
105
+ coderay (~> 1.1)
106
+ method_source (~> 1.0)
99
107
  public_suffix (3.1.1)
100
- rack (2.0.8)
108
+ rack (2.2.3)
101
109
  rack-test (1.1.0)
102
110
  rack (>= 1.0, < 3)
103
111
  rails-dom-testing (2.0.3)
@@ -105,41 +113,41 @@ GEM
105
113
  nokogiri (>= 1.6)
106
114
  rails-html-sanitizer (1.3.0)
107
115
  loofah (~> 2.3)
108
- railties (6.0.2.1)
109
- actionpack (= 6.0.2.1)
110
- activesupport (= 6.0.2.1)
116
+ railties (6.0.3.2)
117
+ actionpack (= 6.0.3.2)
118
+ activesupport (= 6.0.3.2)
111
119
  method_source
112
120
  rake (>= 0.8.7)
113
121
  thor (>= 0.20.3, < 2.0)
114
122
  rake (13.0.1)
115
- regexp_parser (1.6.0)
116
- rspec-core (3.9.0)
117
- rspec-support (~> 3.9.0)
118
- rspec-expectations (3.9.0)
123
+ regexp_parser (1.7.1)
124
+ rspec-core (3.9.2)
125
+ rspec-support (~> 3.9.3)
126
+ rspec-expectations (3.9.2)
119
127
  diff-lcs (>= 1.2.0, < 2.0)
120
128
  rspec-support (~> 3.9.0)
121
- rspec-mocks (3.9.0)
129
+ rspec-mocks (3.9.1)
122
130
  diff-lcs (>= 1.2.0, < 2.0)
123
131
  rspec-support (~> 3.9.0)
124
- rspec-rails (3.9.0)
125
- actionpack (>= 3.0)
126
- activesupport (>= 3.0)
127
- railties (>= 3.0)
128
- rspec-core (~> 3.9.0)
129
- rspec-expectations (~> 3.9.0)
130
- rspec-mocks (~> 3.9.0)
131
- rspec-support (~> 3.9.0)
132
- rspec-support (3.9.0)
133
- shoulda-matchers (4.1.2)
132
+ rspec-rails (4.0.1)
133
+ actionpack (>= 4.2)
134
+ activesupport (>= 4.2)
135
+ railties (>= 4.2)
136
+ rspec-core (~> 3.9)
137
+ rspec-expectations (~> 3.9)
138
+ rspec-mocks (~> 3.9)
139
+ rspec-support (~> 3.9)
140
+ rspec-support (3.9.3)
141
+ shoulda-matchers (4.3.0)
134
142
  activesupport (>= 4.2.0)
135
143
  thor (1.0.1)
136
144
  thread_safe (0.3.6)
137
145
  timecop (0.9.1)
138
- tzinfo (1.2.5)
146
+ tzinfo (1.2.7)
139
147
  thread_safe (~> 0.1)
140
148
  xpath (3.2.0)
141
149
  nokogiri (~> 1.8)
142
- zeitwerk (2.2.2)
150
+ zeitwerk (2.3.1)
143
151
 
144
152
  PLATFORMS
145
153
  ruby
@@ -158,4 +166,4 @@ DEPENDENCIES
158
166
  timecop (~> 0.6)
159
167
 
160
168
  BUNDLED WITH
161
- 1.17.3
169
+ 2.1.2
data/NEWS.md CHANGED
@@ -3,6 +3,22 @@
3
3
  The noteworthy changes for each Clearance version are included here. For a
4
4
  complete changelog, see the git history for each version via the version links.
5
5
 
6
+ ## [2.2.0] - July 9, 2020
7
+
8
+ ### Added
9
+
10
+ - Add an Argon2 password strategy
11
+
12
+ ### Fixed
13
+
14
+ - Use strings instead of classes on guard classes, avoids Rails deprecation
15
+ warning.
16
+ - Use `find_by` style for finders, improves neo4j support
17
+ - Provide explicit case sensitivity option for email uniqueness, avoid Rails
18
+ deprecation warning.
19
+
20
+ [2.2.0]: https://github.com/thoughtbot/clearance/compare/v2.1.0...v2.2.0
21
+
6
22
  ## [2.1.0] - December 19, 2019
7
23
 
8
24
  ### Added
data/README.md CHANGED
@@ -333,7 +333,7 @@ Here's an example custom guard to handle email confirmation:
333
333
 
334
334
  ```ruby
335
335
  Clearance.configure do |config|
336
- config.sign_in_guards = [EmailConfirmationGuard]
336
+ config.sign_in_guards = ["EmailConfirmationGuard"]
337
337
  end
338
338
  ```
339
339
 
@@ -58,7 +58,7 @@ class Clearance::PasswordsController < Clearance::BaseController
58
58
  token = params[:token] || session[:password_reset_token]
59
59
 
60
60
  Clearance.configuration.user_model.
61
- find_by_id_and_confirmation_token params[user_param], token.to_s
61
+ find_by(id: params[user_param], confirmation_token: token.to_s)
62
62
  end
63
63
 
64
64
  def email_from_password_params
@@ -3,6 +3,7 @@ require 'clearance/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.add_dependency 'bcrypt', '>= 3.1.1'
6
+ s.add_dependency 'argon2', '~> 2.0', '>= 2.0.2'
6
7
  s.add_dependency 'email_validator', '~> 2.0'
7
8
  s.add_dependency 'railties', '>= 5.0'
8
9
  s.add_dependency 'activemodel', '>= 5.0'
@@ -13,10 +13,11 @@ module Clearance
13
13
  # `password=(new_password)`. For an example of how to implement these methods,
14
14
  # see {Clearance::PasswordStrategies::BCrypt}.
15
15
  module PasswordStrategies
16
- autoload :BCrypt, 'clearance/password_strategies/bcrypt'
16
+ autoload :BCrypt, "clearance/password_strategies/bcrypt"
17
+ autoload :Argon2, "clearance/password_strategies/argon2"
17
18
  autoload :BCryptMigrationFromSHA1,
18
- 'clearance/password_strategies/bcrypt_migration_from_sha1'
19
- autoload :Blowfish, 'clearance/password_strategies/blowfish'
20
- autoload :SHA1, 'clearance/password_strategies/sha1'
19
+ "clearance/password_strategies/bcrypt_migration_from_sha1"
20
+ autoload :Blowfish, "clearance/password_strategies/blowfish"
21
+ autoload :SHA1, "clearance/password_strategies/sha1"
21
22
  end
22
23
  end
@@ -0,0 +1,23 @@
1
+ module Clearance
2
+ module PasswordStrategies
3
+ # Uses Argon2 to authenticate users and store encrypted passwords.
4
+
5
+ module Argon2
6
+ require "argon2"
7
+
8
+ def authenticated?(password)
9
+ if encrypted_password.present?
10
+ ::Argon2::Password.verify_password(password, encrypted_password)
11
+ end
12
+ end
13
+
14
+ def password=(new_password)
15
+ @password = new_password
16
+
17
+ if new_password.present?
18
+ self.encrypted_password = ::Argon2::Password.new.create(new_password)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -121,7 +121,7 @@ module Clearance
121
121
  end
122
122
 
123
123
  def find_by_normalized_email(email)
124
- find_by_email normalize_email(email)
124
+ find_by(email: normalize_email(email))
125
125
  end
126
126
 
127
127
  def normalize_email(email)
@@ -143,7 +143,7 @@ module Clearance
143
143
  validates :email,
144
144
  email: { strict_mode: true },
145
145
  presence: true,
146
- uniqueness: { allow_blank: true },
146
+ uniqueness: { allow_blank: true, case_sensitive: false },
147
147
  unless: :email_optional?
148
148
 
149
149
  validates :password, presence: true, unless: :skip_password_validation?
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  end
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+
3
+ describe Clearance::PasswordStrategies::Argon2 do
4
+ include FakeModelWithPasswordStrategy
5
+
6
+ describe "#password=" do
7
+ it "encrypts the password into encrypted_password" do
8
+ stub_argon2_password
9
+ model_instance = fake_model_with_argon2_strategy
10
+
11
+ model_instance.password = password
12
+
13
+ expect(model_instance.encrypted_password).to eq encrypted_password
14
+ end
15
+
16
+ it "encrypts with Argon2 using default cost in non test environments" do
17
+ hasher = stub_argon2_password
18
+ model_instance = fake_model_with_argon2_strategy
19
+ allow(Rails).to receive(:env).
20
+ and_return(ActiveSupport::StringInquirer.new("production"))
21
+
22
+ model_instance.password = password
23
+
24
+ expect(hasher).to have_received(:create).with(password)
25
+ end
26
+
27
+ it "encrypts with Argon2 using minimum cost in test environment" do
28
+ hasher = stub_argon2_password
29
+ model_instance = fake_model_with_argon2_strategy
30
+
31
+ model_instance.password = password
32
+
33
+ expect(hasher).to have_received(:create).with(password)
34
+ end
35
+
36
+ def stub_argon2_password
37
+ hasher = double(Argon2::Password)
38
+ allow(hasher).to receive(:create).and_return(encrypted_password)
39
+ allow(Argon2::Password).to receive(:new).and_return(hasher)
40
+ hasher
41
+ end
42
+
43
+ def encrypted_password
44
+ @encrypted_password ||= double("encrypted password")
45
+ end
46
+ end
47
+
48
+ describe "#authenticated?" do
49
+ context "given a password" do
50
+ it "is authenticated with Argon2" do
51
+ model_instance = fake_model_with_argon2_strategy
52
+
53
+ model_instance.password = password
54
+
55
+ expect(model_instance).to be_authenticated(password)
56
+ end
57
+ end
58
+
59
+ context "given no password" do
60
+ it "is not authenticated" do
61
+ model_instance = fake_model_with_argon2_strategy
62
+
63
+ password = nil
64
+
65
+ expect(model_instance).not_to be_authenticated(password)
66
+ end
67
+ end
68
+ end
69
+
70
+ def fake_model_with_argon2_strategy
71
+ @fake_model_with_argon2_strategy ||= fake_model_with_password_strategy(
72
+ Clearance::PasswordStrategies::Argon2,
73
+ )
74
+ end
75
+
76
+ def password
77
+ "password"
78
+ end
79
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -22,10 +22,10 @@ authors:
22
22
  - Jason Morrison
23
23
  - Galen Frechette
24
24
  - Josh Steiner
25
- autorequire:
25
+ autorequire:
26
26
  bindir: bin
27
27
  cert_chain: []
28
- date: 2019-12-19 00:00:00.000000000 Z
28
+ date: 2020-07-09 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt
@@ -41,6 +41,26 @@ dependencies:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 3.1.1
44
+ - !ruby/object:Gem::Dependency
45
+ name: argon2
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '2.0'
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 2.0.2
44
64
  - !ruby/object:Gem::Dependency
45
65
  name: email_validator
46
66
  requirement: !ruby/object:Gem::Requirement
@@ -174,6 +194,7 @@ files:
174
194
  - lib/clearance/default_sign_in_guard.rb
175
195
  - lib/clearance/engine.rb
176
196
  - lib/clearance/password_strategies.rb
197
+ - lib/clearance/password_strategies/argon2.rb
177
198
  - lib/clearance/password_strategies/bcrypt.rb
178
199
  - lib/clearance/rack_session.rb
179
200
  - lib/clearance/rspec.rb
@@ -250,6 +271,7 @@ files:
250
271
  - spec/helpers/helper_helpers_spec.rb
251
272
  - spec/mailers/clearance_mailer_spec.rb
252
273
  - spec/models/user_spec.rb
274
+ - spec/password_strategies/argon2_spec.rb
253
275
  - spec/password_strategies/bcrypt_spec.rb
254
276
  - spec/password_strategies/password_strategies_spec.rb
255
277
  - spec/requests/authentication_cookie_spec.rb
@@ -270,7 +292,7 @@ homepage: https://github.com/thoughtbot/clearance
270
292
  licenses:
271
293
  - MIT
272
294
  metadata: {}
273
- post_install_message:
295
+ post_install_message:
274
296
  rdoc_options:
275
297
  - "--charset=UTF-8"
276
298
  require_paths:
@@ -286,8 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
308
  - !ruby/object:Gem::Version
287
309
  version: '0'
288
310
  requirements: []
289
- rubygems_version: 3.0.3
290
- signing_key:
311
+ rubygems_version: 3.1.2
312
+ signing_key:
291
313
  specification_version: 4
292
314
  summary: Rails authentication & authorization with email & password.
293
315
  test_files: []