clearance 2.10.0 → 2.12.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/.github/workflows/codeql.yml +39 -0
- data/.github/workflows/standardrb.yml +22 -0
- data/.github/workflows/tests.yml +8 -4
- data/Appraisals +4 -5
- data/CHANGELOG.md +68 -1
- data/CODEOWNERS +2 -0
- data/Gemfile +18 -14
- data/Gemfile.lock +146 -106
- data/README.md +1 -3
- data/Rakefile +1 -1
- data/app/controllers/clearance/passwords_controller.rb +9 -9
- data/app/controllers/clearance/users_controller.rb +1 -1
- data/app/mailers/clearance_mailer.rb +1 -1
- data/clearance.gemspec +39 -38
- data/config/routes.rb +7 -7
- data/gemfiles/rails_7.2.gemfile +5 -1
- data/gemfiles/rails_8.0.gemfile +4 -0
- data/gemfiles/{rails_7.1.gemfile → rails_8.1.gemfile} +6 -2
- data/lib/clearance/authentication.rb +4 -0
- data/lib/clearance/back_door.rb +3 -3
- data/lib/clearance/configuration.rb +6 -6
- data/lib/clearance/constraints.rb +2 -2
- data/lib/clearance/controller.rb +2 -2
- data/lib/clearance/default_sign_in_guard.rb +1 -1
- data/lib/clearance/password_strategies/bcrypt.rb +2 -2
- data/lib/clearance/session.rb +4 -6
- data/lib/clearance/sign_in_guard.rb +1 -1
- data/lib/clearance/testing/deny_access_matcher.rb +4 -4
- data/lib/clearance/token.rb +1 -1
- data/lib/clearance/user.rb +7 -7
- data/lib/clearance/version.rb +1 -1
- data/lib/clearance.rb +10 -10
- data/lib/generators/clearance/install/install_generator.rb +16 -15
- data/lib/generators/clearance/routes/routes_generator.rb +5 -5
- data/lib/generators/clearance/routes/templates/routes.rb +10 -10
- data/lib/generators/clearance/specs/specs_generator.rb +4 -4
- data/lib/generators/clearance/views/views_generator.rb +4 -4
- data/spec/acceptance/clearance_installation_spec.rb +3 -3
- data/spec/clearance/back_door_spec.rb +5 -5
- data/spec/clearance/constraints/signed_in_spec.rb +14 -14
- data/spec/clearance/constraints/signed_out_spec.rb +4 -4
- data/spec/clearance/default_sign_in_guard_spec.rb +6 -6
- data/spec/clearance/rack_session_spec.rb +9 -9
- data/spec/clearance/session_spec.rb +60 -62
- data/spec/clearance/sign_in_guard_spec.rb +7 -7
- data/spec/clearance/testing/controller_helpers_spec.rb +15 -14
- data/spec/clearance/testing/deny_access_matcher_spec.rb +2 -1
- data/spec/clearance/testing/view_helpers_spec.rb +2 -2
- data/spec/clearance/token_spec.rb +3 -3
- data/spec/configuration_spec.rb +8 -21
- data/spec/controllers/apis_controller_spec.rb +2 -2
- data/spec/controllers/forgeries_controller_spec.rb +12 -12
- data/spec/controllers/passwords_controller_spec.rb +28 -28
- data/spec/controllers/permissions_controller_spec.rb +12 -12
- data/spec/controllers/sessions_controller_spec.rb +6 -6
- data/spec/controllers/users_controller_spec.rb +6 -6
- data/spec/dummy/config/environments/test.rb +3 -3
- data/spec/factories/users.rb +3 -3
- data/spec/generators/clearance/install/install_generator_spec.rb +11 -11
- data/spec/generators/clearance/routes/routes_generator_spec.rb +1 -1
- data/spec/generators/clearance/specs/specs_generator_spec.rb +2 -2
- data/spec/generators/clearance/views/views_generator_spec.rb +2 -2
- data/spec/mailers/clearance_mailer_spec.rb +3 -2
- data/spec/models/user_spec.rb +2 -2
- data/spec/password_strategies/argon2_spec.rb +3 -3
- data/spec/password_strategies/bcrypt_spec.rb +5 -4
- data/spec/password_strategies/password_strategies_spec.rb +2 -1
- data/spec/requests/authentication_cookie_spec.rb +4 -3
- data/spec/requests/backdoor_spec.rb +1 -1
- data/spec/requests/cookie_options_spec.rb +2 -2
- data/spec/requests/csrf_rotation_spec.rb +1 -1
- data/spec/requests/password_maintenance_spec.rb +1 -1
- data/spec/requests/token_expiration_spec.rb +2 -2
- data/spec/routing/clearance_routes_spec.rb +36 -36
- data/spec/support/clearance.rb +1 -1
- data/spec/support/fake_model_without_password_strategy.rb +5 -2
- data/spec/support/generator_spec_helpers.rb +2 -2
- data/spec/support/request_with_remember_token.rb +1 -1
- metadata +7 -4
|
@@ -5,7 +5,7 @@ Rails.application.configure do
|
|
|
5
5
|
|
|
6
6
|
config.eager_load = ENV["CI"].present?
|
|
7
7
|
|
|
8
|
-
config.public_file_server.headers = {
|
|
8
|
+
config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{1.hour.to_i}"}
|
|
9
9
|
|
|
10
10
|
# Show full error reports and disable caching.
|
|
11
11
|
config.consider_all_requests_local = true
|
|
@@ -19,13 +19,13 @@ Rails.application.configure do
|
|
|
19
19
|
config.action_mailer.perform_caching = false
|
|
20
20
|
config.action_mailer.delivery_method = :test
|
|
21
21
|
|
|
22
|
-
config.action_mailer.default_url_options = {
|
|
22
|
+
config.action_mailer.default_url_options = {host: "www.example.com"}
|
|
23
23
|
|
|
24
24
|
config.active_support.deprecation = :stderr
|
|
25
25
|
config.active_support.disallowed_deprecation = :raise
|
|
26
26
|
config.active_support.disallowed_deprecation_warnings = []
|
|
27
27
|
|
|
28
|
-
config.factory_bot.definition_file_paths = [File.expand_path(
|
|
28
|
+
config.factory_bot.definition_file_paths = [File.expand_path("../../../factories", __dir__)]
|
|
29
29
|
|
|
30
30
|
config.middleware.use Clearance::BackDoor
|
|
31
31
|
end
|
data/spec/factories/users.rb
CHANGED
|
@@ -5,15 +5,15 @@ FactoryBot.define do
|
|
|
5
5
|
|
|
6
6
|
factory :user do
|
|
7
7
|
email
|
|
8
|
-
password {
|
|
8
|
+
password { "password" }
|
|
9
9
|
|
|
10
10
|
trait :with_forgotten_password do
|
|
11
11
|
confirmation_token { Clearance::Token.new }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
factory :user_with_optional_password, class:
|
|
14
|
+
factory :user_with_optional_password, class: "UserWithOptionalPassword" do
|
|
15
15
|
password { nil }
|
|
16
|
-
encrypted_password {
|
|
16
|
+
encrypted_password { "" }
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -117,13 +117,13 @@ describe Clearance::Generators::InstallGenerator, :generator do
|
|
|
117
117
|
existing_columns = [Struct::Named.new("remember_token")]
|
|
118
118
|
existing_indexes = [Struct::Named.new("index_users_on_remember_token")]
|
|
119
119
|
|
|
120
|
-
allow(ActiveRecord::Base.connection).to receive(:columns)
|
|
121
|
-
with(:users)
|
|
122
|
-
and_return(existing_columns)
|
|
120
|
+
allow(ActiveRecord::Base.connection).to receive(:columns)
|
|
121
|
+
.with(:users)
|
|
122
|
+
.and_return(existing_columns)
|
|
123
123
|
|
|
124
|
-
allow(ActiveRecord::Base.connection).to receive(:indexes)
|
|
125
|
-
with(:users)
|
|
126
|
-
and_return(existing_indexes)
|
|
124
|
+
allow(ActiveRecord::Base.connection).to receive(:indexes)
|
|
125
|
+
.with(:users)
|
|
126
|
+
.and_return(existing_indexes)
|
|
127
127
|
|
|
128
128
|
run_generator
|
|
129
129
|
migration = migration_file("db/migrate/add_clearance_to_users.rb")
|
|
@@ -136,10 +136,10 @@ describe Clearance::Generators::InstallGenerator, :generator do
|
|
|
136
136
|
expect(migration).not_to contain("t.string :remember_token")
|
|
137
137
|
expect(migration).not_to contain("add_index :users, :remember_token")
|
|
138
138
|
expect(migration).to(
|
|
139
|
-
contain("add_index :users, :confirmation_token, unique: true")
|
|
139
|
+
contain("add_index :users, :confirmation_token, unique: true")
|
|
140
140
|
)
|
|
141
141
|
expect(migration).to(
|
|
142
|
-
contain("remove_index :users, :confirmation_token, unique: true")
|
|
142
|
+
contain("remove_index :users, :confirmation_token, unique: true")
|
|
143
143
|
)
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -147,9 +147,9 @@ describe Clearance::Generators::InstallGenerator, :generator do
|
|
|
147
147
|
|
|
148
148
|
def table_does_not_exist(name)
|
|
149
149
|
connection = ActiveRecord::Base.connection
|
|
150
|
-
allow(connection).to receive(:data_source_exists?)
|
|
151
|
-
with(name)
|
|
152
|
-
and_return(false)
|
|
150
|
+
allow(connection).to receive(:data_source_exists?)
|
|
151
|
+
.with(name)
|
|
152
|
+
.and_return(false)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
def preserve_original_primary_key_type_setting
|
|
@@ -15,7 +15,7 @@ describe Clearance::Generators::RoutesGenerator, :generator do
|
|
|
15
15
|
expect(initializer).to contain("config.routes = false")
|
|
16
16
|
expect(routes).to have_correct_syntax
|
|
17
17
|
expect(routes).to contain(
|
|
18
|
-
'get "/sign_in" => "clearance/sessions#new", as
|
|
18
|
+
'get "/sign_in" => "clearance/sessions#new", :as => "sign_in"'
|
|
19
19
|
)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -5,7 +5,7 @@ describe Clearance::Generators::SpecsGenerator, :generator do
|
|
|
5
5
|
it "copies specs to host app" do
|
|
6
6
|
run_generator
|
|
7
7
|
|
|
8
|
-
specs = %w
|
|
8
|
+
specs = %w[
|
|
9
9
|
factories/clearance
|
|
10
10
|
features/clearance/user_signs_out_spec
|
|
11
11
|
features/clearance/visitor_resets_password_spec
|
|
@@ -14,7 +14,7 @@ describe Clearance::Generators::SpecsGenerator, :generator do
|
|
|
14
14
|
features/clearance/visitor_updates_password_spec
|
|
15
15
|
support/clearance
|
|
16
16
|
support/features/clearance_helpers
|
|
17
|
-
|
|
17
|
+
]
|
|
18
18
|
|
|
19
19
|
spec_files = specs.map { |spec| file("spec/#{spec}.rb") }
|
|
20
20
|
|
|
@@ -5,7 +5,7 @@ describe Clearance::Generators::ViewsGenerator, :generator do
|
|
|
5
5
|
it "copies clearance views to the host application" do
|
|
6
6
|
run_generator
|
|
7
7
|
|
|
8
|
-
views = %w
|
|
8
|
+
views = %w[
|
|
9
9
|
clearance_mailer/change_password.html.erb
|
|
10
10
|
clearance_mailer/change_password.text.erb
|
|
11
11
|
passwords/create.html.erb
|
|
@@ -15,7 +15,7 @@ describe Clearance::Generators::ViewsGenerator, :generator do
|
|
|
15
15
|
sessions/new.html.erb
|
|
16
16
|
users/_form.html.erb
|
|
17
17
|
users/new.html.erb
|
|
18
|
-
|
|
18
|
+
]
|
|
19
19
|
|
|
20
20
|
view_files = views.map { |view| file("app/views/#{view}") }
|
|
21
21
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
+
Person = Class.new(User)
|
|
4
|
+
|
|
3
5
|
describe ClearanceMailer do
|
|
4
6
|
it "is from DO_NOT_REPLY" do
|
|
5
7
|
user = create(:user)
|
|
@@ -59,7 +61,6 @@ describe ClearanceMailer do
|
|
|
59
61
|
context "when using a custom model" do
|
|
60
62
|
it "contains a link for a custom model" do
|
|
61
63
|
define_people_routes
|
|
62
|
-
Person = Class.new(User)
|
|
63
64
|
person = Person.new(email: "person@example.com", password: "password")
|
|
64
65
|
|
|
65
66
|
person.forgot_password!
|
|
@@ -82,7 +83,7 @@ describe ClearanceMailer do
|
|
|
82
83
|
resource(
|
|
83
84
|
:password,
|
|
84
85
|
controller: "clearance/passwords",
|
|
85
|
-
only: %i[edit update]
|
|
86
|
+
only: %i[edit update]
|
|
86
87
|
)
|
|
87
88
|
end
|
|
88
89
|
end
|
data/spec/models/user_spec.rb
CHANGED
|
@@ -60,7 +60,7 @@ describe User do
|
|
|
60
60
|
User.authenticate("bad_email@example.com", password)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
expect(user_does_not_exist_time).
|
|
63
|
+
expect(user_does_not_exist_time).to be_within(0.01).of(user_exists_time)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "takes the same amount of time to fail authentication regardless of whether user exists" do
|
|
@@ -74,7 +74,7 @@ describe User do
|
|
|
74
74
|
User.authenticate("bad_email@example.com", "bad_password")
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
expect(user_does_not_exist_time).
|
|
77
|
+
expect(user_does_not_exist_time).to be_within(0.01).of(user_exists_time)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "is retrieved via a case-insensitive search" do
|
|
@@ -16,8 +16,8 @@ describe Clearance::PasswordStrategies::Argon2 do
|
|
|
16
16
|
it "encrypts with Argon2 using default cost in non test environments" do
|
|
17
17
|
hasher = stub_argon2_password
|
|
18
18
|
model_instance = fake_model_with_argon2_strategy
|
|
19
|
-
allow(Rails).to receive(:env)
|
|
20
|
-
and_return(ActiveSupport::StringInquirer.new("production"))
|
|
19
|
+
allow(Rails).to receive(:env)
|
|
20
|
+
.and_return(ActiveSupport::StringInquirer.new("production"))
|
|
21
21
|
|
|
22
22
|
model_instance.password = password
|
|
23
23
|
|
|
@@ -69,7 +69,7 @@ describe Clearance::PasswordStrategies::Argon2 do
|
|
|
69
69
|
|
|
70
70
|
def fake_model_with_argon2_strategy
|
|
71
71
|
@fake_model_with_argon2_strategy ||= fake_model_with_password_strategy(
|
|
72
|
-
Clearance::PasswordStrategies::Argon2
|
|
72
|
+
Clearance::PasswordStrategies::Argon2
|
|
73
73
|
)
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
include FakeModelWithPasswordStrategy
|
|
3
2
|
|
|
4
3
|
describe Clearance::PasswordStrategies::BCrypt do
|
|
4
|
+
include FakeModelWithPasswordStrategy
|
|
5
|
+
|
|
5
6
|
describe "#password=" do
|
|
6
7
|
it "encrypts the password into encrypted_password" do
|
|
7
8
|
stub_bcrypt_password
|
|
@@ -15,14 +16,14 @@ describe Clearance::PasswordStrategies::BCrypt do
|
|
|
15
16
|
it "encrypts with BCrypt using default cost in non test environments" do
|
|
16
17
|
stub_bcrypt_password
|
|
17
18
|
model_instance = fake_model_with_bcrypt_strategy
|
|
18
|
-
allow(Rails).to receive(:env)
|
|
19
|
-
and_return(ActiveSupport::StringInquirer.new("production"))
|
|
19
|
+
allow(Rails).to receive(:env)
|
|
20
|
+
.and_return(ActiveSupport::StringInquirer.new("production"))
|
|
20
21
|
|
|
21
22
|
model_instance.password = password
|
|
22
23
|
|
|
23
24
|
expect(BCrypt::Password).to have_received(:create).with(
|
|
24
25
|
password,
|
|
25
|
-
cost: ::BCrypt::Engine::DEFAULT_COST
|
|
26
|
+
cost: ::BCrypt::Engine::DEFAULT_COST
|
|
26
27
|
)
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
include FakeModelWithoutPasswordStrategy
|
|
3
2
|
|
|
4
3
|
describe "Password strategy configuration" do
|
|
4
|
+
include FakeModelWithoutPasswordStrategy
|
|
5
|
+
|
|
5
6
|
describe "when Clearance.configuration.password_strategy is set" do
|
|
6
7
|
it "includes the value it is set to" do
|
|
7
8
|
mock_password_strategy = Module.new
|
|
@@ -2,6 +2,7 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
class PagesController < ApplicationController
|
|
4
4
|
include Clearance::Controller
|
|
5
|
+
|
|
5
6
|
before_action :require_login, only: :private
|
|
6
7
|
|
|
7
8
|
# A page requiring user authentication
|
|
@@ -39,8 +40,8 @@ describe "Authentication cookies in the response" do
|
|
|
39
40
|
|
|
40
41
|
def draw_test_routes
|
|
41
42
|
Rails.application.routes.draw do
|
|
42
|
-
get "/private" => "pages#private", as
|
|
43
|
-
get "/public" => "pages#public", as
|
|
43
|
+
get "/private" => "pages#private", :as => :private
|
|
44
|
+
get "/public" => "pages#public", :as => :public
|
|
44
45
|
resource :session, controller: "clearance/sessions", only: [:create]
|
|
45
46
|
end
|
|
46
47
|
end
|
|
@@ -49,7 +50,7 @@ describe "Authentication cookies in the response" do
|
|
|
49
50
|
user = create(:user, password: "password")
|
|
50
51
|
|
|
51
52
|
post session_path, params: {
|
|
52
|
-
session: {
|
|
53
|
+
session: {email: user.email, password: "password"}
|
|
53
54
|
}
|
|
54
55
|
end
|
|
55
56
|
end
|
|
@@ -12,7 +12,7 @@ describe "Backdoor Middleware" do
|
|
|
12
12
|
it "removes the `as` param but leaves other parameters unchanged" do
|
|
13
13
|
user = create(:user)
|
|
14
14
|
|
|
15
|
-
get root_path(as: user.to_param, foo:
|
|
15
|
+
get root_path(as: user.to_param, foo: "bar")
|
|
16
16
|
|
|
17
17
|
expect(response.body).to include('{"foo":"bar","controller":"application","action":"show"}')
|
|
18
18
|
end
|
|
@@ -13,7 +13,7 @@ describe "Cookie options" do
|
|
|
13
13
|
get sign_in_path
|
|
14
14
|
|
|
15
15
|
post session_path, params: {
|
|
16
|
-
session: {
|
|
16
|
+
session: {email: user.email, password: "password"}
|
|
17
17
|
}
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -33,7 +33,7 @@ describe "Cookie options" do
|
|
|
33
33
|
get sign_in_path
|
|
34
34
|
|
|
35
35
|
post session_path, params: {
|
|
36
|
-
session: {
|
|
36
|
+
session: {email: user.email, password: "password"}
|
|
37
37
|
}
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -16,7 +16,7 @@ describe "CSRF Rotation" do
|
|
|
16
16
|
original_token = csrf_token
|
|
17
17
|
|
|
18
18
|
post session_path, params: {
|
|
19
|
-
authenticity_token: csrf_token, session: {
|
|
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
|
|
@@ -8,7 +8,7 @@ describe "Password maintenance" do
|
|
|
8
8
|
put user_password_url(user), params: {
|
|
9
9
|
user_id: user,
|
|
10
10
|
token: user.confirmation_token,
|
|
11
|
-
password_reset: {
|
|
11
|
+
password_reset: {password: "my_new_password"}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
expect(response).to redirect_to(Clearance.configuration.redirect_url)
|
|
@@ -15,7 +15,7 @@ describe "Token expiration" do
|
|
|
15
15
|
it "should have a remember_token cookie with a future expiration" do
|
|
16
16
|
expect(first_cookie.expires).to be_between(
|
|
17
17
|
1.years.from_now - 1.second,
|
|
18
|
-
1.years.from_now
|
|
18
|
+
1.years.from_now
|
|
19
19
|
)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -53,7 +53,7 @@ describe "Token expiration" do
|
|
|
53
53
|
get sign_in_path
|
|
54
54
|
|
|
55
55
|
post session_path, params: {
|
|
56
|
-
session: {
|
|
56
|
+
session: {email: user.email, password: "password"}
|
|
57
57
|
}
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
context
|
|
5
|
-
it
|
|
6
|
-
expect(get:
|
|
7
|
-
expect(get:
|
|
8
|
-
expect(get:
|
|
9
|
-
expect(post:
|
|
10
|
-
expect(post:
|
|
11
|
-
expect(post:
|
|
3
|
+
describe "routes for Clearance" do
|
|
4
|
+
context "routes enabled" do
|
|
5
|
+
it "draws the default routes" do
|
|
6
|
+
expect(get: "sign_up").to be_routable
|
|
7
|
+
expect(get: "sign_in").to be_routable
|
|
8
|
+
expect(get: "passwords/new").to be_routable
|
|
9
|
+
expect(post: "session").to be_routable
|
|
10
|
+
expect(post: "passwords").to be_routable
|
|
11
|
+
expect(post: "users").to be_routable
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
context
|
|
15
|
+
context "routes disabled" do
|
|
16
16
|
around do |example|
|
|
17
17
|
Clearance.configure { |config| config.routes = false }
|
|
18
18
|
Rails.application.reload_routes!
|
|
@@ -21,17 +21,17 @@ describe 'routes for Clearance' do
|
|
|
21
21
|
Rails.application.reload_routes!
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it
|
|
25
|
-
expect(get:
|
|
26
|
-
expect(get:
|
|
27
|
-
expect(get:
|
|
28
|
-
expect(post:
|
|
29
|
-
expect(post:
|
|
30
|
-
expect(post:
|
|
24
|
+
it "does not draw any routes" do
|
|
25
|
+
expect(get: "sign_up").not_to be_routable
|
|
26
|
+
expect(get: "sign_in").not_to be_routable
|
|
27
|
+
expect(get: "passwords/new").not_to be_routable
|
|
28
|
+
expect(post: "session").not_to be_routable
|
|
29
|
+
expect(post: "passwords").not_to be_routable
|
|
30
|
+
expect(post: "users").not_to be_routable
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
context
|
|
34
|
+
context "signup disabled" do
|
|
35
35
|
around do |example|
|
|
36
36
|
Clearance.configure { |config| config.allow_sign_up = false }
|
|
37
37
|
Rails.application.reload_routes!
|
|
@@ -40,30 +40,30 @@ describe 'routes for Clearance' do
|
|
|
40
40
|
Rails.application.reload_routes!
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
it
|
|
44
|
-
expect(get:
|
|
43
|
+
it "does not route sign_up" do
|
|
44
|
+
expect(get: "sign_up").not_to be_routable
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
it
|
|
48
|
-
expect(post:
|
|
47
|
+
it "does not route to users#create" do
|
|
48
|
+
expect(post: "users").not_to be_routable
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
it
|
|
52
|
-
expect(get:
|
|
51
|
+
it "does not route to users#new" do
|
|
52
|
+
expect(get: "users/new").not_to be_routable
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
context
|
|
57
|
-
it
|
|
58
|
-
expect(get:
|
|
56
|
+
context "signup enabled" do
|
|
57
|
+
it "does route sign_up" do
|
|
58
|
+
expect(get: "sign_up").to be_routable
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
it
|
|
62
|
-
expect(post:
|
|
61
|
+
it "does route to users#create" do
|
|
62
|
+
expect(post: "users").to be_routable
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
context
|
|
66
|
+
context "password reset disabled" do
|
|
67
67
|
around do |example|
|
|
68
68
|
Clearance.configure { |config| config.allow_password_reset = false }
|
|
69
69
|
Rails.application.reload_routes!
|
|
@@ -72,24 +72,24 @@ describe 'routes for Clearance' do
|
|
|
72
72
|
Rails.application.reload_routes!
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
it
|
|
75
|
+
it "does not route password edit" do
|
|
76
76
|
user = create(:user)
|
|
77
77
|
expect(get: "users/#{user.id}/password/edit").not_to be_routable
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
it
|
|
80
|
+
it "does not route to clearance/passwords#update" do
|
|
81
81
|
user = create(:user)
|
|
82
82
|
expect(patch: "/users/#{user.id}/password").not_to be_routable
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
context
|
|
87
|
-
it
|
|
86
|
+
context "reset enabled" do
|
|
87
|
+
it "does route password edit" do
|
|
88
88
|
user = create(:user)
|
|
89
89
|
expect(get: "users/#{user.id}/password/edit").to be_routable
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
it
|
|
92
|
+
it "does route to clearance/passwords#update" do
|
|
93
93
|
user = create(:user)
|
|
94
94
|
expect(patch: "/users/#{user.id}/password").to be_routable
|
|
95
95
|
end
|
data/spec/support/clearance.rb
CHANGED
|
@@ -5,8 +5,11 @@ module FakeModelWithoutPasswordStrategy
|
|
|
5
5
|
|
|
6
6
|
validates_with UniquenessValidator
|
|
7
7
|
|
|
8
|
-
def self.before_validation(*)
|
|
9
|
-
|
|
8
|
+
def self.before_validation(*)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.before_create(*)
|
|
12
|
+
end
|
|
10
13
|
|
|
11
14
|
include Clearance::User
|
|
12
15
|
end.new
|
|
@@ -7,7 +7,7 @@ module RememberTokenHelpers
|
|
|
7
7
|
cookies[Clearance.configuration.cookie_name] = remember_token
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
env = {
|
|
10
|
+
env = {clearance: Clearance::Session.new(cookies.request.env)}
|
|
11
11
|
Rack::Request.new env
|
|
12
12
|
end
|
|
13
13
|
|
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.
|
|
4
|
+
version: 2.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Croak
|
|
@@ -24,10 +24,11 @@ authors:
|
|
|
24
24
|
- Josh Steiner
|
|
25
25
|
- Dorian Marié
|
|
26
26
|
- Sara Jackson
|
|
27
|
+
- Fernando Perales
|
|
27
28
|
autorequire:
|
|
28
29
|
bindir: bin
|
|
29
30
|
cert_chain: []
|
|
30
|
-
date:
|
|
31
|
+
date: 2026-04-17 00:00:00.000000000 Z
|
|
31
32
|
dependencies:
|
|
32
33
|
- !ruby/object:Gem::Dependency
|
|
33
34
|
name: bcrypt
|
|
@@ -148,8 +149,10 @@ extra_rdoc_files:
|
|
|
148
149
|
files:
|
|
149
150
|
- ".erb_lint.yml"
|
|
150
151
|
- ".github/dependabot.yml"
|
|
152
|
+
- ".github/workflows/codeql.yml"
|
|
151
153
|
- ".github/workflows/dynamic-readme.yml"
|
|
152
154
|
- ".github/workflows/dynamic-security.yml"
|
|
155
|
+
- ".github/workflows/standardrb.yml"
|
|
153
156
|
- ".github/workflows/tests.yml"
|
|
154
157
|
- ".gitignore"
|
|
155
158
|
- ".yardopts"
|
|
@@ -185,9 +188,9 @@ files:
|
|
|
185
188
|
- clearance.gemspec
|
|
186
189
|
- config/locales/clearance.en.yml
|
|
187
190
|
- config/routes.rb
|
|
188
|
-
- gemfiles/rails_7.1.gemfile
|
|
189
191
|
- gemfiles/rails_7.2.gemfile
|
|
190
192
|
- gemfiles/rails_8.0.gemfile
|
|
193
|
+
- gemfiles/rails_8.1.gemfile
|
|
191
194
|
- lib/clearance.rb
|
|
192
195
|
- lib/clearance/authentication.rb
|
|
193
196
|
- lib/clearance/authorization.rb
|
|
@@ -316,7 +319,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
316
319
|
requirements:
|
|
317
320
|
- - ">="
|
|
318
321
|
- !ruby/object:Gem::Version
|
|
319
|
-
version: 3.
|
|
322
|
+
version: 3.3.11
|
|
320
323
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
324
|
requirements:
|
|
322
325
|
- - ">="
|