clearance 2.8.0 → 2.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5f7f15515653096a81f567271c72a5bc138dac396acb3d7727fb7eb95b89540
4
- data.tar.gz: 61b53d47ef673fe4f171aa32c6239c80fca531c4edaa239446bb0f3d8478df18
3
+ metadata.gz: b3164482da14d878bfca32632ebbabf81635add8143adaca1be3baa7ec41cd83
4
+ data.tar.gz: 037f0f5a5c30f3022b0d29a9c100e40538c0b176b4935c061ec96c469d8c3ca9
5
5
  SHA512:
6
- metadata.gz: a695e60bfb14845d6bb5a1481766f2104f68fc92149fc0de3191af403bc7719803013cb8cb4a93fa74c1d334d1190e7206ba017502d40f109d0e96fb381fb3e0
7
- data.tar.gz: cc12e0563b4106d22e4d4c23a8d2f50621cc1f2a61f905ea82ea697369e1e916bc5e5d69b65900d8b146244fe9a8dbf50e54e752c9b0cbd9243c53c285011226
6
+ metadata.gz: 5b889666cb2a46f6bfdcf41b9aaf9c7f0414b986f07ab4f31bb4846d3b4ef900f3d6076d50d9f8463657033488b118472d9e8dace8c4786aadd0f2999f5b2bed
7
+ data.tar.gz: 0fbc755f11f689843852ef18201963d0d56be06b8bf22326e82d2c83162d092ade4af85dfff3469867e0cf3937f545351a84b83425094cfb064d3466c361dd7c
@@ -16,20 +16,20 @@ jobs:
16
16
  fail-fast: false
17
17
  matrix:
18
18
  gemfile:
19
- - "6.1"
20
19
  - "7.0"
21
20
  - "7.1"
21
+ - "7.2"
22
22
  ruby:
23
- - "3.0.4"
24
- - "3.1.2"
25
- - "3.2.2"
23
+ - "3.1.6"
24
+ - "3.2.5"
25
+ - "3.3.5"
26
26
 
27
27
  env:
28
28
  BUNDLE_GEMFILE: gemfiles/rails_${{ matrix.gemfile }}.gemfile
29
29
  RAILS_ENV: test
30
30
 
31
31
  steps:
32
- - uses: actions/checkout@v2
32
+ - uses: actions/checkout@v4
33
33
 
34
34
  - name: "Install Ruby ${{ matrix.ruby }}"
35
35
  uses: ruby/setup-ruby@v1
@@ -39,8 +39,8 @@ jobs:
39
39
 
40
40
  - name: "Reset app database"
41
41
  run: |
42
- bundle exec rake dummy:db:drop
43
- bundle exec rake dummy:db:setup
42
+ bundle exec rake db:drop
43
+ bundle exec rake db:setup
44
44
 
45
45
  - name: "Run tests"
46
46
  run: bundle exec rake
data/.gitignore CHANGED
@@ -4,7 +4,10 @@
4
4
  *.swp
5
5
  *~
6
6
  .bundle
7
- db/*.sqlite3
7
+ .idea
8
+ .tool-versions
9
+ spec/dummy/db/*.sqlite3*
10
+ spec/dummy/log
8
11
  gemfiles/*.lock
9
12
  gemfiles/vendor/
10
13
  log/*.log
data/Appraisals CHANGED
@@ -1,12 +1,16 @@
1
- appraise "rails_6.1" do
2
- gem "railties", "~> 6.1.0"
3
- gem "net-smtp", require: false # not bundled in ruby 3.1
4
- end
5
-
6
1
  appraise "rails_7.0" do
7
2
  gem "railties", "~> 7.0.0"
3
+ # The following gems will not be bundled with Ruby 3.4
4
+ gem "base64", require: false
5
+ gem "bigdecimal", require: false
6
+ gem "drb", require: false
7
+ gem "mutex_m", require: false
8
8
  end
9
9
 
10
10
  appraise "rails_7.1" do
11
11
  gem "railties", "~> 7.1.0"
12
12
  end
13
+
14
+ appraise "rails_7.2" do
15
+ gem "railties", "~> 7.2.0"
16
+ end
data/CHANGELOG.md CHANGED
@@ -5,7 +5,17 @@ complete changelog, see the git history for each version via the version links.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
- [Unreleased]: https://github.com/thoughtbot/clearance/compare/v2.8.0...main
8
+ [Unreleased]: https://github.com/thoughtbot/clearance/compare/v2.9.1...main
9
+
10
+ ## [2.9.1] - October 29, 2024
11
+ - Update gemspec
12
+
13
+ ## [2.9.0] - October 29, 2024
14
+ - Added Rails 7.2 and Ruby 3.3 to testing matrix
15
+ and overhauled dummy app (#1032) Hamed Asghari
16
+ - Droped support for Ruby 3.0 and Rails 6.1 (#1036)
17
+
18
+ [2.9.0]: https://github.com/thoughtbot/clearance/compare/v2.8.0...v2.9.0
9
19
 
10
20
  ## [2.8.0] - August 9, 2024
11
21
  - Feature: Added allow_password_resets config option (#1019) Jos O'shea
data/Gemfile CHANGED
@@ -15,4 +15,3 @@ gem 'rails-controller-testing'
15
15
  gem 'rspec-rails'
16
16
  gem 'shoulda-matchers'
17
17
  gem 'sqlite3', '~> 1.7'
18
- gem 'timecop'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (2.8.0)
4
+ clearance (2.9.1)
5
5
  actionmailer (>= 5.0)
6
6
  activemodel (>= 5.0)
7
7
  activerecord (>= 5.0)
@@ -13,49 +13,57 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- actionmailer (7.0.3)
17
- actionpack (= 7.0.3)
18
- actionview (= 7.0.3)
19
- activejob (= 7.0.3)
20
- activesupport (= 7.0.3)
21
- mail (~> 2.5, >= 2.5.4)
22
- net-imap
23
- net-pop
24
- net-smtp
25
- rails-dom-testing (~> 2.0)
26
- actionpack (7.0.3)
27
- actionview (= 7.0.3)
28
- activesupport (= 7.0.3)
29
- rack (~> 2.0, >= 2.2.0)
16
+ actionmailer (7.2.0)
17
+ actionpack (= 7.2.0)
18
+ actionview (= 7.2.0)
19
+ activejob (= 7.2.0)
20
+ activesupport (= 7.2.0)
21
+ mail (>= 2.8.0)
22
+ rails-dom-testing (~> 2.2)
23
+ actionpack (7.2.0)
24
+ actionview (= 7.2.0)
25
+ activesupport (= 7.2.0)
26
+ nokogiri (>= 1.8.5)
27
+ racc
28
+ rack (>= 2.2.4, < 3.2)
29
+ rack-session (>= 1.0.1)
30
30
  rack-test (>= 0.6.3)
31
- rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
33
- actionview (7.0.3)
34
- activesupport (= 7.0.3)
31
+ rails-dom-testing (~> 2.2)
32
+ rails-html-sanitizer (~> 1.6)
33
+ useragent (~> 0.16)
34
+ actionview (7.2.0)
35
+ activesupport (= 7.2.0)
35
36
  builder (~> 3.1)
36
- erubi (~> 1.4)
37
- rails-dom-testing (~> 2.0)
38
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
39
- activejob (7.0.3)
40
- activesupport (= 7.0.3)
37
+ erubi (~> 1.11)
38
+ rails-dom-testing (~> 2.2)
39
+ rails-html-sanitizer (~> 1.6)
40
+ activejob (7.2.0)
41
+ activesupport (= 7.2.0)
41
42
  globalid (>= 0.3.6)
42
- activemodel (7.0.3)
43
- activesupport (= 7.0.3)
44
- activerecord (7.0.3)
45
- activemodel (= 7.0.3)
46
- activesupport (= 7.0.3)
47
- activesupport (7.0.3)
48
- concurrent-ruby (~> 1.0, >= 1.0.2)
43
+ activemodel (7.2.0)
44
+ activesupport (= 7.2.0)
45
+ activerecord (7.2.0)
46
+ activemodel (= 7.2.0)
47
+ activesupport (= 7.2.0)
48
+ timeout (>= 0.4.0)
49
+ activesupport (7.2.0)
50
+ base64
51
+ bigdecimal
52
+ concurrent-ruby (~> 1.0, >= 1.3.1)
53
+ connection_pool (>= 2.2.5)
54
+ drb
49
55
  i18n (>= 1.6, < 2)
56
+ logger (>= 1.4.2)
50
57
  minitest (>= 5.1)
51
- tzinfo (~> 2.0)
52
- addressable (2.8.0)
53
- public_suffix (>= 2.0.2, < 5.0)
54
- ammeter (1.1.5)
58
+ securerandom (>= 0.3)
59
+ tzinfo (~> 2.0, >= 2.0.5)
60
+ addressable (2.8.7)
61
+ public_suffix (>= 2.0.2, < 7.0)
62
+ ammeter (1.1.7)
55
63
  activesupport (>= 3.0)
56
64
  railties (>= 3.0)
57
65
  rspec-rails (>= 2.2)
58
- appraisal (2.4.1)
66
+ appraisal (2.5.0)
59
67
  bundler
60
68
  rake
61
69
  thor (>= 0.14.0)
@@ -63,6 +71,7 @@ GEM
63
71
  ffi (~> 1.15)
64
72
  ffi-compiler (~> 1.0)
65
73
  ast (2.4.2)
74
+ base64 (0.2.0)
66
75
  bcrypt (3.1.20)
67
76
  better_html (2.1.1)
68
77
  actionview (>= 6.0)
@@ -71,41 +80,44 @@ GEM
71
80
  erubi (~> 1.4)
72
81
  parser (>= 2.4)
73
82
  smart_properties
74
- builder (3.2.4)
75
- capybara (3.37.1)
83
+ bigdecimal (3.1.8)
84
+ builder (3.3.0)
85
+ capybara (3.40.0)
76
86
  addressable
77
87
  matrix
78
88
  mini_mime (>= 0.1.3)
79
- nokogiri (~> 1.8)
89
+ nokogiri (~> 1.11)
80
90
  rack (>= 1.6.0)
81
91
  rack-test (>= 0.6.3)
82
92
  regexp_parser (>= 1.5, < 3.0)
83
93
  xpath (~> 3.2)
84
94
  coderay (1.1.3)
85
- concurrent-ruby (1.2.3)
95
+ concurrent-ruby (1.3.4)
96
+ connection_pool (2.4.1)
86
97
  crass (1.0.6)
87
- database_cleaner (2.0.1)
88
- database_cleaner-active_record (~> 2.0.0)
89
- database_cleaner-active_record (2.0.1)
98
+ database_cleaner (2.0.2)
99
+ database_cleaner-active_record (>= 2, < 3)
100
+ database_cleaner-active_record (2.2.0)
90
101
  activerecord (>= 5.a)
91
102
  database_cleaner-core (~> 2.0.0)
92
103
  database_cleaner-core (2.0.1)
93
104
  date (3.3.4)
94
- diff-lcs (1.5.0)
105
+ diff-lcs (1.5.1)
106
+ drb (2.2.1)
95
107
  email_validator (2.2.4)
96
108
  activemodel
97
- erb_lint (0.5.0)
109
+ erb_lint (0.6.0)
98
110
  activesupport
99
111
  better_html (>= 2.0.1)
100
112
  parser (>= 2.7.1.4)
101
113
  rainbow
102
- rubocop
114
+ rubocop (>= 1)
103
115
  smart_properties
104
- erubi (1.12.0)
105
- factory_bot (6.2.1)
116
+ erubi (1.13.0)
117
+ factory_bot (6.4.6)
106
118
  activesupport (>= 5.0.0)
107
- factory_bot_rails (6.2.0)
108
- factory_bot (~> 6.2.0)
119
+ factory_bot_rails (6.4.3)
120
+ factory_bot (~> 6.4)
109
121
  railties (>= 5.0.0)
110
122
  ffi (1.17.0)
111
123
  ffi-compiler (1.3.2)
@@ -115,8 +127,13 @@ GEM
115
127
  activesupport (>= 6.1)
116
128
  i18n (1.14.5)
117
129
  concurrent-ruby (~> 1.0)
130
+ io-console (0.7.2)
131
+ irb (1.14.0)
132
+ rdoc (>= 4.0.0)
133
+ reline (>= 0.4.2)
118
134
  json (2.7.2)
119
135
  language_server-protocol (3.17.0.3)
136
+ logger (1.6.0)
120
137
  loofah (2.22.0)
121
138
  crass (~> 1.0.2)
122
139
  nokogiri (>= 1.12.0)
@@ -126,11 +143,11 @@ GEM
126
143
  net-pop
127
144
  net-smtp
128
145
  matrix (0.4.2)
129
- method_source (1.0.0)
130
- mini_mime (1.1.2)
131
- mini_portile2 (2.8.6)
132
- minitest (5.22.3)
133
- net-imap (0.4.14)
146
+ method_source (1.1.0)
147
+ mini_mime (1.1.5)
148
+ mini_portile2 (2.8.7)
149
+ minitest (5.25.1)
150
+ net-imap (0.5.0)
134
151
  date
135
152
  net-protocol
136
153
  net-pop (0.1.2)
@@ -139,21 +156,28 @@ GEM
139
156
  timeout
140
157
  net-smtp (0.5.0)
141
158
  net-protocol
142
- nokogiri (1.16.4)
159
+ nokogiri (1.16.7)
143
160
  mini_portile2 (~> 2.8.2)
144
161
  racc (~> 1.4)
145
- parallel (1.24.0)
146
- parser (3.3.1.0)
162
+ parallel (1.26.3)
163
+ parser (3.3.4.2)
147
164
  ast (~> 2.4.1)
148
165
  racc
149
- pry (0.14.1)
166
+ pry (0.14.2)
150
167
  coderay (~> 1.1)
151
168
  method_source (~> 1.0)
152
- public_suffix (4.0.7)
153
- racc (1.7.3)
154
- rack (2.2.3.1)
155
- rack-test (1.1.0)
156
- rack (>= 1.0, < 3)
169
+ psych (5.1.2)
170
+ stringio
171
+ public_suffix (6.0.1)
172
+ racc (1.8.1)
173
+ rack (3.1.7)
174
+ rack-session (2.0.0)
175
+ rack (>= 3.0.0)
176
+ rack-test (2.1.0)
177
+ rack (>= 1.3)
178
+ rackup (2.1.0)
179
+ rack (>= 3)
180
+ webrick (~> 1.8)
157
181
  rails-controller-testing (1.0.5)
158
182
  actionpack (>= 5.0.1.rc1)
159
183
  actionview (>= 5.0.1.rc1)
@@ -165,62 +189,72 @@ GEM
165
189
  rails-html-sanitizer (1.6.0)
166
190
  loofah (~> 2.21)
167
191
  nokogiri (~> 1.14)
168
- railties (7.0.3)
169
- actionpack (= 7.0.3)
170
- activesupport (= 7.0.3)
171
- method_source
192
+ railties (7.2.0)
193
+ actionpack (= 7.2.0)
194
+ activesupport (= 7.2.0)
195
+ irb (~> 1.13)
196
+ rackup (>= 1.0.0)
172
197
  rake (>= 12.2)
173
- thor (~> 1.0)
174
- zeitwerk (~> 2.5)
198
+ thor (~> 1.0, >= 1.2.2)
199
+ zeitwerk (~> 2.6)
175
200
  rainbow (3.1.1)
176
- rake (13.1.0)
177
- regexp_parser (2.9.0)
178
- rexml (3.2.6)
179
- rspec-core (3.11.0)
180
- rspec-support (~> 3.11.0)
181
- rspec-expectations (3.11.0)
201
+ rake (13.2.1)
202
+ rdoc (6.7.0)
203
+ psych (>= 4.0.0)
204
+ regexp_parser (2.9.2)
205
+ reline (0.5.9)
206
+ io-console (~> 0.5)
207
+ rexml (3.3.5)
208
+ strscan
209
+ rspec-core (3.13.0)
210
+ rspec-support (~> 3.13.0)
211
+ rspec-expectations (3.13.1)
182
212
  diff-lcs (>= 1.2.0, < 2.0)
183
- rspec-support (~> 3.11.0)
184
- rspec-mocks (3.11.1)
213
+ rspec-support (~> 3.13.0)
214
+ rspec-mocks (3.13.1)
185
215
  diff-lcs (>= 1.2.0, < 2.0)
186
- rspec-support (~> 3.11.0)
187
- rspec-rails (5.1.2)
188
- actionpack (>= 5.2)
189
- activesupport (>= 5.2)
190
- railties (>= 5.2)
191
- rspec-core (~> 3.10)
192
- rspec-expectations (~> 3.10)
193
- rspec-mocks (~> 3.10)
194
- rspec-support (~> 3.10)
195
- rspec-support (3.11.0)
196
- rubocop (1.63.4)
216
+ rspec-support (~> 3.13.0)
217
+ rspec-rails (6.1.4)
218
+ actionpack (>= 6.1)
219
+ activesupport (>= 6.1)
220
+ railties (>= 6.1)
221
+ rspec-core (~> 3.13)
222
+ rspec-expectations (~> 3.13)
223
+ rspec-mocks (~> 3.13)
224
+ rspec-support (~> 3.13)
225
+ rspec-support (3.13.1)
226
+ rubocop (1.65.1)
197
227
  json (~> 2.3)
198
228
  language_server-protocol (>= 3.17.0)
199
229
  parallel (~> 1.10)
200
230
  parser (>= 3.3.0.2)
201
231
  rainbow (>= 2.2.2, < 4.0)
202
- regexp_parser (>= 1.8, < 3.0)
232
+ regexp_parser (>= 2.4, < 3.0)
203
233
  rexml (>= 3.2.5, < 4.0)
204
234
  rubocop-ast (>= 1.31.1, < 2.0)
205
235
  ruby-progressbar (~> 1.7)
206
236
  unicode-display_width (>= 2.4.0, < 3.0)
207
- rubocop-ast (1.31.3)
237
+ rubocop-ast (1.32.1)
208
238
  parser (>= 3.3.1.0)
209
239
  ruby-progressbar (1.13.0)
210
- shoulda-matchers (5.1.0)
240
+ securerandom (0.3.1)
241
+ shoulda-matchers (6.4.0)
211
242
  activesupport (>= 5.2.0)
212
243
  smart_properties (1.17.0)
213
244
  sqlite3 (1.7.3)
214
245
  mini_portile2 (~> 2.8.0)
215
- thor (1.2.1)
216
- timecop (0.9.5)
246
+ stringio (3.1.1)
247
+ strscan (3.1.0)
248
+ thor (1.3.1)
217
249
  timeout (0.4.1)
218
250
  tzinfo (2.0.6)
219
251
  concurrent-ruby (~> 1.0)
220
252
  unicode-display_width (2.5.0)
253
+ useragent (0.16.10)
254
+ webrick (1.8.1)
221
255
  xpath (3.2.0)
222
256
  nokogiri (~> 1.8)
223
- zeitwerk (2.5.4)
257
+ zeitwerk (2.6.17)
224
258
 
225
259
  PLATFORMS
226
260
  ruby
@@ -240,7 +274,6 @@ DEPENDENCIES
240
274
  rspec-rails
241
275
  shoulda-matchers
242
276
  sqlite3 (~> 1.7)
243
- timecop
244
277
 
245
278
  BUNDLED WITH
246
279
  2.3.15
data/README.md CHANGED
@@ -18,7 +18,7 @@ monitored by contributors.
18
18
 
19
19
  ## Getting Started
20
20
 
21
- Clearance is a Rails engine tested against Rails `>= 6.1` and Ruby `>= 3.0.0`.
21
+ Clearance is a Rails engine tested against Rails `>= 7.0` and Ruby `>= 3.1.6`.
22
22
 
23
23
  You can add it to your Gemfile with:
24
24
 
data/Rakefile CHANGED
@@ -1,15 +1,12 @@
1
- require "rubygems"
2
1
  require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
3
6
  require "bundler/gem_tasks"
4
7
 
5
- require "rake"
6
8
  require "rspec/core/rake_task"
7
9
 
8
- namespace :dummy do
9
- require_relative "spec/dummy/application"
10
- Dummy::Application.load_tasks
11
- end
12
-
13
10
  desc "Run specs other than spec/acceptance"
14
11
  RSpec::Core::RakeTask.new("spec") do |task|
15
12
  task.exclude_pattern = "spec/acceptance/**/*_spec.rb"
data/bin/setup CHANGED
@@ -12,5 +12,5 @@ if [ -z "$CI" ]; then
12
12
  fi
13
13
 
14
14
  # Set up database for the application that Clearance tests against
15
- RAILS_ENV=test bundle exec rake dummy:db:drop
16
- RAILS_ENV=test bundle exec rake dummy:db:setup
15
+ RAILS_ENV=test bundle exec rake db:drop
16
+ RAILS_ENV=test bundle exec rake db:setup
data/clearance.gemspec CHANGED
@@ -1,5 +1,4 @@
1
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
- require 'clearance/version'
1
+ require_relative 'lib/clearance/version'
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.add_dependency 'bcrypt', '>= 3.1.1'
@@ -46,7 +45,7 @@ Gem::Specification.new do |s|
46
45
  s.name = %q{clearance}
47
46
  s.rdoc_options = ['--charset=UTF-8']
48
47
  s.require_paths = ['lib']
49
- s.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
48
+ s.required_ruby_version = Gem::Requirement.new('>= 3.1.6')
50
49
  s.summary = 'Rails authentication & authorization with email & password.'
51
50
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
52
51
  s.version = Clearance::VERSION
@@ -15,7 +15,10 @@ gem "rails-controller-testing"
15
15
  gem "rspec-rails"
16
16
  gem "shoulda-matchers"
17
17
  gem "sqlite3", "~> 1.7"
18
- gem "timecop"
19
18
  gem "railties", "~> 7.0.0"
19
+ gem "base64", require: false
20
+ gem "bigdecimal", require: false
21
+ gem "drb", require: false
22
+ gem "mutex_m", require: false
20
23
 
21
24
  gemspec path: "../"
@@ -15,7 +15,6 @@ gem "rails-controller-testing"
15
15
  gem "rspec-rails"
16
16
  gem "shoulda-matchers"
17
17
  gem "sqlite3", "~> 1.7"
18
- gem "timecop"
19
18
  gem "railties", "~> 7.1.0"
20
19
 
21
20
  gemspec path: "../"
@@ -15,8 +15,6 @@ gem "rails-controller-testing"
15
15
  gem "rspec-rails"
16
16
  gem "shoulda-matchers"
17
17
  gem "sqlite3", "~> 1.7"
18
- gem "timecop"
19
- gem "railties", "~> 6.1.0"
20
- gem "net-smtp", require: false
18
+ gem "railties", "~> 7.2.0"
21
19
 
22
20
  gemspec path: "../"
@@ -48,11 +48,13 @@ module Clearance
48
48
 
49
49
  # @api private
50
50
  def sign_in_through_the_back_door(env)
51
- params = Rack::Utils.parse_query(env["QUERY_STRING"])
51
+ params = Rack::Utils.parse_query(env[Rack::QUERY_STRING])
52
52
  user_param = params.delete("as")
53
53
 
54
54
  if user_param.present?
55
- env["QUERY_STRING"] = Rack::Utils.build_query(params)
55
+ query_string = Rack::Utils.build_query(params)
56
+ env[Rack::QUERY_STRING] = query_string
57
+ env[Rack::RACK_REQUEST_QUERY_STRING] = query_string
56
58
  user = find_user(user_param)
57
59
  env[:clearance].sign_in(user)
58
60
  end
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = "2.8.0".freeze
2
+ VERSION = "2.9.1".freeze
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Clearance::Session do
4
- before { Timecop.freeze }
5
- after { Timecop.return }
4
+ before { freeze_time }
5
+ after { unfreeze_time }
6
6
 
7
7
  let(:session) { Clearance::Session.new(env_without_remember_token) }
8
8
  let(:user) { create(:user) }
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ config.load_defaults Rails::VERSION::STRING.to_f
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
3
+
4
+ require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
5
+ $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,31 @@
1
+ require "active_support/core_ext/integer/time"
2
+
3
+ Rails.application.configure do
4
+ config.enable_reloading = false
5
+
6
+ config.eager_load = ENV["CI"].present?
7
+
8
+ config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
9
+
10
+ # Show full error reports and disable caching.
11
+ config.consider_all_requests_local = true
12
+ config.action_controller.perform_caching = false
13
+ config.cache_store = :null_store
14
+
15
+ config.action_dispatch.show_exceptions = :rescuable
16
+
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ config.action_mailer.perform_caching = false
20
+ config.action_mailer.delivery_method = :test
21
+
22
+ config.action_mailer.default_url_options = { host: "www.example.com" }
23
+
24
+ config.active_support.deprecation = :stderr
25
+ config.active_support.disallowed_deprecation = :raise
26
+ config.active_support.disallowed_deprecation_warnings = []
27
+
28
+ config.factory_bot.definition_file_paths = [File.expand_path('../../../factories', __dir__)]
29
+
30
+ config.middleware.use Clearance::BackDoor
31
+ end
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -1,4 +1,4 @@
1
- class CreateClearanceUsers < ActiveRecord::Migration
1
+ class CreateClearanceUsers < ActiveRecord::Migration[Rails::VERSION::STRING.to_f]
2
2
  def self.up
3
3
  create_table :users do |t|
4
4
  t.timestamps null: false
@@ -9,7 +9,8 @@ class CreateClearanceUsers < ActiveRecord::Migration
9
9
  end
10
10
 
11
11
  add_index :users, :email
12
- add_index :users, :remember_token
12
+ add_index :users, :confirmation_token, unique: true
13
+ add_index :users, :remember_token, unique: true
13
14
  end
14
15
 
15
16
  def self.down
@@ -0,0 +1,25 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 2011_01_11_224543) do
14
+ create_table "users", force: :cascade do |t|
15
+ t.datetime "created_at", null: false
16
+ t.datetime "updated_at", null: false
17
+ t.string "email", null: false
18
+ t.string "encrypted_password", limit: 128, null: false
19
+ t.string "confirmation_token", limit: 128
20
+ t.string "remember_token", limit: 128, null: false
21
+ t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
22
+ t.index ["email"], name: "index_users_on_email"
23
+ t.index ["remember_token"], name: "index_users_on_remember_token", unique: true
24
+ end
25
+ end
@@ -2,10 +2,6 @@ require "spec_helper"
2
2
  require "generators/clearance/install/install_generator"
3
3
 
4
4
  describe Clearance::Generators::InstallGenerator, :generator do
5
- def get_migration(path)
6
- Pathname.new(migration_file(path))
7
- end
8
-
9
5
  describe "initializer" do
10
6
  it "is copied to the application" do
11
7
  provide_existing_application_controller
@@ -70,7 +66,7 @@ describe Clearance::Generators::InstallGenerator, :generator do
70
66
  table_does_not_exist(:users)
71
67
 
72
68
  run_generator
73
- migration = get_migration("db/migrate/create_users.rb")
69
+ migration = migration_file("db/migrate/create_users.rb")
74
70
 
75
71
  expect(migration).to exist
76
72
  expect(migration).to have_correct_syntax
@@ -92,7 +88,7 @@ describe Clearance::Generators::InstallGenerator, :generator do
92
88
  table_does_not_exist(:users)
93
89
 
94
90
  run_generator
95
- migration = get_migration("db/migrate/create_users.rb")
91
+ migration = migration_file("db/migrate/create_users.rb")
96
92
 
97
93
  expect(migration).to exist
98
94
  expect(migration).to have_correct_syntax
@@ -106,8 +102,8 @@ describe Clearance::Generators::InstallGenerator, :generator do
106
102
  provide_existing_application_controller
107
103
 
108
104
  run_generator
109
- create_migration = get_migration("db/migrate/create_users.rb")
110
- add_migration = get_migration("db/migrate/add_clearance_to_users.rb")
105
+ create_migration = migration_file("db/migrate/create_users.rb")
106
+ add_migration = migration_file("db/migrate/add_clearance_to_users.rb")
111
107
 
112
108
  expect(create_migration).not_to exist
113
109
  expect(add_migration).not_to exist
@@ -130,7 +126,7 @@ describe Clearance::Generators::InstallGenerator, :generator do
130
126
  and_return(existing_indexes)
131
127
 
132
128
  run_generator
133
- migration = get_migration("db/migrate/add_clearance_to_users.rb")
129
+ migration = migration_file("db/migrate/add_clearance_to_users.rb")
134
130
 
135
131
  expect(migration).to exist
136
132
  expect(migration).to have_correct_syntax
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe "Backdoor Middleware" do
4
+ it "allows signing in using query parameter" do
5
+ user = create(:user)
6
+
7
+ get root_path(as: user.to_param)
8
+
9
+ expect(cookies["remember_token"]).to eq user.remember_token
10
+ end
11
+ end
@@ -16,7 +16,7 @@ describe "CSRF Rotation" do
16
16
  original_token = csrf_token
17
17
 
18
18
  post session_path, params: {
19
- session: session_params(user, "password"),
19
+ authenticity_token: csrf_token, session: { email: user.email, password: "password" }
20
20
  }
21
21
 
22
22
  expect(csrf_token).not_to eq original_token
@@ -28,8 +28,4 @@ describe "CSRF Rotation" do
28
28
  def csrf_token
29
29
  session[:_csrf_token]
30
30
  end
31
-
32
- def session_params(user, password)
33
- { email: user.email, password: password, authenticity_token: csrf_token }
34
- end
35
31
  end
@@ -3,13 +3,13 @@ require "spec_helper"
3
3
  describe "Token expiration" do
4
4
  describe "after signing in" do
5
5
  before do
6
- Timecop.freeze
6
+ freeze_time
7
7
  create_user_and_sign_in
8
8
  @initial_cookies = remember_token_cookies
9
9
  end
10
10
 
11
11
  after do
12
- Timecop.return
12
+ unfreeze_time
13
13
  end
14
14
 
15
15
  it "should have a remember_token cookie with a future expiration" do
@@ -25,7 +25,7 @@ describe "Token expiration" do
25
25
  create_user_and_sign_in
26
26
  @initial_cookies = remember_token_cookies
27
27
 
28
- Timecop.travel(1.minute.from_now) do
28
+ travel_to(1.minute.from_now) do
29
29
  get root_path
30
30
  @followup_cookies = remember_token_cookies
31
31
  end
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,13 @@
1
1
  ENV["RAILS_ENV"] ||= "test"
2
+ require_relative "dummy/config/environment"
2
3
 
3
- require "rails/all"
4
- require "dummy/application"
5
-
6
- require "clearance/rspec"
7
- require "factory_bot_rails"
8
- require "rails-controller-testing"
9
4
  require "rspec/rails"
10
- require "shoulda-matchers"
11
- require "timecop"
12
-
13
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
5
+ require "clearance/rspec"
14
6
 
15
- Dummy::Application.initialize!
7
+ Dir[File.expand_path("spec/support/**/*.rb")].each { |f| require f }
16
8
 
17
9
  RSpec.configure do |config|
10
+ config.include ActiveSupport::Testing::TimeHelpers
18
11
  config.include FactoryBot::Syntax::Methods
19
12
  config.infer_spec_type_from_file_location!
20
13
  config.order = :random
@@ -3,6 +3,16 @@ require "ammeter/rspec/generator/matchers.rb"
3
3
  require "ammeter/init"
4
4
 
5
5
  module GeneratorSpecHelpers
6
+ module FileMethods
7
+ def file(path)
8
+ Pathname.new(super)
9
+ end
10
+
11
+ def migration_file(path)
12
+ Pathname.new(super)
13
+ end
14
+ end
15
+
6
16
  TEMPLATE_PATH = File.expand_path("../../app_templates", __FILE__)
7
17
 
8
18
  def provide_existing_routes_file
@@ -36,6 +46,7 @@ end
36
46
 
37
47
  RSpec.configure do |config|
38
48
  config.include GeneratorSpecHelpers
49
+ config.prepend GeneratorSpecHelpers::FileMethods
39
50
 
40
51
  config.before(:example, :generator) do
41
52
  destination File.expand_path("../../../tmp", __FILE__)
@@ -1,6 +1,6 @@
1
1
  module HTMLEscapeHelper
2
2
  def translated_string(key)
3
- if Rails.version >= "7.0"
3
+ if [7.0].include?(Rails::VERSION::STRING.to_f)
4
4
  ERB::Util.html_escape_once(I18n.t(key))
5
5
  else
6
6
  I18n.t(key)
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.8.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -27,7 +27,7 @@ authors:
27
27
  autorequire:
28
28
  bindir: bin
29
29
  cert_chain: []
30
- date: 2024-08-09 00:00:00.000000000 Z
30
+ date: 2024-10-29 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bcrypt
@@ -185,11 +185,9 @@ files:
185
185
  - clearance.gemspec
186
186
  - config/locales/clearance.en.yml
187
187
  - config/routes.rb
188
- - db/migrate/20110111224543_create_clearance_users.rb
189
- - db/schema.rb
190
- - gemfiles/rails_6.1.gemfile
191
188
  - gemfiles/rails_7.0.gemfile
192
189
  - gemfiles/rails_7.1.gemfile
190
+ - gemfiles/rails_7.2.gemfile
193
191
  - lib/clearance.rb
194
192
  - lib/clearance/authentication.rb
195
193
  - lib/clearance/authorization.rb
@@ -265,14 +263,22 @@ files:
265
263
  - spec/controllers/permissions_controller_spec.rb
266
264
  - spec/controllers/sessions_controller_spec.rb
267
265
  - spec/controllers/users_controller_spec.rb
266
+ - spec/dummy/Rakefile
267
+ - spec/dummy/app/assets/config/manifest.js
268
268
  - spec/dummy/app/controllers/application_controller.rb
269
269
  - spec/dummy/app/models/user.rb
270
270
  - spec/dummy/app/models/user_with_optional_password.rb
271
- - spec/dummy/application.rb
271
+ - spec/dummy/config.ru
272
+ - spec/dummy/config/application.rb
273
+ - spec/dummy/config/boot.rb
272
274
  - spec/dummy/config/database.yml
275
+ - spec/dummy/config/environment.rb
276
+ - spec/dummy/config/environments/test.rb
273
277
  - spec/dummy/config/routes.rb
274
278
  - spec/dummy/db/.keep
275
- - spec/factories.rb
279
+ - spec/dummy/db/migrate/20110111224543_create_clearance_users.rb
280
+ - spec/dummy/db/schema.rb
281
+ - spec/factories/users.rb
276
282
  - spec/generators/clearance/install/install_generator_spec.rb
277
283
  - spec/generators/clearance/routes/routes_generator_spec.rb
278
284
  - spec/generators/clearance/specs/specs_generator_spec.rb
@@ -284,6 +290,7 @@ files:
284
290
  - spec/password_strategies/bcrypt_spec.rb
285
291
  - spec/password_strategies/password_strategies_spec.rb
286
292
  - spec/requests/authentication_cookie_spec.rb
293
+ - spec/requests/backdoor_spec.rb
287
294
  - spec/requests/cookie_options_spec.rb
288
295
  - spec/requests/csrf_rotation_spec.rb
289
296
  - spec/requests/password_maintenance_spec.rb
@@ -291,7 +298,6 @@ files:
291
298
  - spec/routing/clearance_routes_spec.rb
292
299
  - spec/spec_helper.rb
293
300
  - spec/support/clearance.rb
294
- - spec/support/cookies.rb
295
301
  - spec/support/fake_model_with_password_strategy.rb
296
302
  - spec/support/fake_model_without_password_strategy.rb
297
303
  - spec/support/generator_spec_helpers.rb
@@ -311,14 +317,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
311
317
  requirements:
312
318
  - - ">="
313
319
  - !ruby/object:Gem::Version
314
- version: 2.4.0
320
+ version: 3.1.6
315
321
  required_rubygems_version: !ruby/object:Gem::Requirement
316
322
  requirements:
317
323
  - - ">="
318
324
  - !ruby/object:Gem::Version
319
325
  version: '0'
320
326
  requirements: []
321
- rubygems_version: 3.5.15
327
+ rubygems_version: 3.5.16
322
328
  signing_key:
323
329
  specification_version: 4
324
330
  summary: Rails authentication & authorization with email & password.
data/db/schema.rb DELETED
@@ -1,28 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20110111224543) do
15
-
16
- create_table "users", force: true do |t|
17
- t.datetime "created_at", null: false
18
- t.datetime "updated_at", null: false
19
- t.string "email", null: false
20
- t.string "encrypted_password", limit: 128, null: false
21
- t.string "confirmation_token", limit: 128
22
- t.string "remember_token", limit: 128, null: false
23
- end
24
-
25
- add_index "users", ["email"], name: "index_users_on_email"
26
- add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
27
- add_index "users", ["remember_token"], name: "index_users_on_remember_token", unique: true
28
- end
@@ -1,33 +0,0 @@
1
- require "rails/all"
2
-
3
- require "clearance"
4
-
5
- module Dummy
6
- APP_ROOT = File.expand_path("..", __FILE__).freeze
7
-
8
- class Application < Rails::Application
9
- config.action_controller.perform_caching = false
10
- config.action_mailer.default_url_options = { host: "dummy.example.com" }
11
- config.action_mailer.delivery_method = :test
12
- if Rails.version.match?(/(6.1|7.0)/)
13
- config.active_record.legacy_connection_handling = false
14
- end
15
- config.active_support.deprecation = :stderr
16
- config.eager_load = false
17
-
18
- config.paths["app/controllers"] << "#{APP_ROOT}/app/controllers"
19
- config.paths["app/models"] << "#{APP_ROOT}/app/models"
20
- config.paths["app/views"] << "#{APP_ROOT}/app/views"
21
- config.paths["config/database"] = "#{APP_ROOT}/config/database.yml"
22
- config.paths["log"] = "tmp/log/development.log"
23
- config.paths.add "config/routes.rb", with: "#{APP_ROOT}/config/routes.rb"
24
-
25
- def require_environment!
26
- initialize!
27
- end
28
-
29
- def initialize!(&block)
30
- super unless @initialized
31
- end
32
- end
33
- end
@@ -1,74 +0,0 @@
1
- RSpec::Matchers.define :set_cookie do |name, expected_value, expected_expires_at|
2
- failure_message do
3
- "Expected #{expectation} got #{result}"
4
- end
5
-
6
- match do |subject|
7
- @headers = subject
8
- @expected_name = name
9
- @expected_value = expected_value
10
- @expected_expires_at = expected_expires_at
11
- extract_cookies
12
- find_expected_cookie
13
- parse_expiration
14
- parse_value
15
- parse_path
16
- ensure_cookie_set
17
- ensure_expiration_correct
18
- ensure_path_is_correct
19
- end
20
-
21
- def ensure_cookie_set
22
- expect(@value).to eq @expected_value
23
- end
24
-
25
- def ensure_expiration_correct
26
- expect(@expires_at).not_to be_nil
27
- expect(@expires_at).to be_within(100).of(@expected_expires_at)
28
- end
29
-
30
- def ensure_path_is_correct
31
- expect(@path).to eq '/'
32
- end
33
-
34
- def expectation
35
- "a cookie named #{@expected_name} with value #{@expected_value.inspect} expiring at #{@expected_expires_at.inspect}"
36
- end
37
-
38
- def extract_cookies
39
- @cookie_headers = @headers["Set-Cookie"] || @headers["set-cookie"] || []
40
- @cookie_headers = [@cookie_headers] if @cookie_headers.respond_to?(:to_str)
41
- end
42
-
43
- def find_expected_cookie
44
- @cookie = @cookie_headers.detect do |header|
45
- header =~ /^#{@expected_name}=[^;]*(;|$)/
46
- end
47
- end
48
-
49
- def parse_expiration
50
- if @cookie && result = @cookie.match(/; expires=(.*?)(;|$)/)
51
- @expires_at = Time.parse(result[1])
52
- end
53
- end
54
-
55
- def parse_path
56
- if @cookie && result = @cookie.match(/; path=(.*?)(;|$)/)
57
- @path = result[1]
58
- end
59
- end
60
-
61
- def parse_value
62
- if @cookie && result = @cookie.match(/=(.*?)(?:;|$)/)
63
- @value = result[1]
64
- end
65
- end
66
-
67
- def result
68
- if @cookie
69
- @cookie
70
- else
71
- @cookie_headers.join("; ")
72
- end
73
- end
74
- end
File without changes