clearance 1.8.0 → 1.13.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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +24 -6
- data/.yardopts +6 -0
- data/Appraisals +12 -4
- data/CONTRIBUTING.md +4 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +87 -85
- data/NEWS.md +672 -311
- data/README.md +185 -330
- data/app/controllers/clearance/passwords_controller.rb +25 -19
- data/app/controllers/clearance/sessions_controller.rb +17 -4
- data/app/controllers/clearance/users_controller.rb +10 -4
- data/app/mailers/clearance_mailer.rb +2 -3
- data/app/views/clearance_mailer/change_password.html.erb +6 -3
- data/app/views/clearance_mailer/change_password.text.erb +5 -0
- data/app/views/layouts/application.html.erb +2 -2
- data/app/views/passwords/create.html.erb +1 -1
- data/app/views/passwords/edit.html.erb +2 -2
- data/app/views/passwords/new.html.erb +2 -2
- data/app/views/sessions/_form.html.erb +2 -2
- data/app/views/sessions/new.html.erb +1 -1
- data/app/views/users/new.html.erb +2 -2
- data/bin/setup +6 -2
- data/config/locales/clearance.en.yml +6 -0
- data/db/migrate/20110111224543_create_clearance_users.rb +1 -1
- data/gemfiles/{rails3.2.gemfile → rails32.gemfile} +1 -1
- data/gemfiles/{rails4.0.gemfile → rails40.gemfile} +2 -2
- data/gemfiles/{rails4.1.gemfile → rails41.gemfile} +2 -2
- data/gemfiles/{rails4.2.gemfile → rails42.gemfile} +2 -2
- data/gemfiles/rails50.gemfile +19 -0
- data/lib/clearance/authentication.rb +52 -1
- data/lib/clearance/authorization.rb +47 -4
- data/lib/clearance/back_door.rb +1 -0
- data/lib/clearance/configuration.rb +127 -15
- data/lib/clearance/constraints/signed_in.rb +21 -0
- data/lib/clearance/constraints/signed_out.rb +12 -0
- data/lib/clearance/constraints.rb +12 -0
- data/lib/clearance/controller.rb +13 -0
- data/lib/clearance/default_sign_in_guard.rb +17 -0
- data/lib/clearance/engine.rb +24 -4
- data/lib/clearance/password_strategies/bcrypt.rb +9 -2
- data/lib/clearance/password_strategies/bcrypt_migration_from_sha1.rb +19 -0
- data/lib/clearance/password_strategies/blowfish.rb +17 -0
- data/lib/clearance/password_strategies/sha1.rb +17 -0
- data/lib/clearance/password_strategies.rb +13 -0
- data/lib/clearance/rack_session.rb +13 -0
- data/lib/clearance/rspec.rb +15 -4
- data/lib/clearance/session.rb +46 -1
- data/lib/clearance/session_status.rb +7 -0
- data/lib/clearance/sign_in_guard.rb +65 -0
- data/lib/clearance/test_unit.rb +3 -3
- data/lib/clearance/testing/controller_helpers.rb +44 -0
- data/lib/clearance/testing/deny_access_matcher.rb +35 -1
- data/lib/clearance/testing/helpers.rb +9 -25
- data/lib/clearance/testing/view_helpers.rb +32 -0
- data/lib/clearance/token.rb +7 -0
- data/lib/clearance/user.rb +159 -0
- data/lib/clearance/version.rb +1 -1
- data/lib/clearance.rb +2 -0
- data/lib/generators/clearance/install/install_generator.rb +13 -3
- data/lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb +3 -3
- data/lib/generators/clearance/install/templates/db/migrate/create_users.rb +2 -2
- data/lib/generators/clearance/routes/routes_generator.rb +23 -0
- data/lib/generators/clearance/routes/templates/routes.rb +7 -7
- data/lib/generators/clearance/specs/templates/features/clearance/user_signs_out_spec.rb.tt +1 -1
- data/lib/generators/clearance/specs/templates/features/clearance/visitor_resets_password_spec.rb.tt +12 -2
- data/lib/generators/clearance/specs/templates/features/clearance/visitor_signs_in_spec.rb.tt +1 -1
- data/lib/generators/clearance/specs/templates/features/clearance/visitor_signs_up_spec.rb.tt +1 -1
- data/lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb.tt +1 -1
- data/spec/acceptance/clearance_installation_spec.rb +4 -1
- data/spec/app_templates/config/initializers/clearance.rb +2 -0
- data/spec/app_templates/testapp/app/controllers/home_controller.rb +5 -1
- data/spec/app_templates/testapp/config/initializers/action_mailer.rb +1 -3
- data/spec/clearance/controller_spec.rb +11 -0
- data/spec/clearance/rack_session_spec.rb +5 -5
- data/spec/clearance/testing/{helpers_spec.rb → controller_helpers_spec.rb} +12 -12
- data/spec/clearance/testing/view_helpers_spec.rb +37 -0
- data/spec/configuration_spec.rb +24 -0
- data/spec/controllers/apis_controller_spec.rb +6 -2
- data/spec/controllers/forgeries_controller_spec.rb +6 -1
- data/spec/controllers/passwords_controller_spec.rb +1 -11
- data/spec/controllers/permissions_controller_spec.rb +13 -3
- data/spec/controllers/sessions_controller_spec.rb +4 -4
- data/spec/dummy/app/controllers/application_controller.rb +5 -1
- data/spec/dummy/application.rb +4 -0
- data/spec/generators/clearance/install/install_generator_spec.rb +15 -3
- data/spec/generators/clearance/routes/routes_generator_spec.rb +5 -1
- data/spec/generators/clearance/views/views_generator_spec.rb +11 -10
- data/spec/helpers/helper_helpers_spec.rb +10 -0
- data/spec/mailers/clearance_mailer_spec.rb +13 -19
- data/spec/password_strategies/bcrypt_migration_from_sha1_spec.rb +6 -0
- data/spec/password_strategies/blowfish_spec.rb +6 -0
- data/spec/password_strategies/sha1_spec.rb +6 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/generator_spec_helpers.rb +4 -0
- data/spec/support/http_method_shim.rb +23 -0
- data/spec/user_spec.rb +9 -0
- data/spec/views/view_helpers_spec.rb +10 -0
- metadata +19 -8
@@ -19,18 +19,6 @@ describe ClearanceMailer do
|
|
19
19
|
expect(email.to.first).to eq(user.email)
|
20
20
|
end
|
21
21
|
|
22
|
-
it "contains a link to edit the password" do
|
23
|
-
user = create(:user)
|
24
|
-
user.forgot_password!
|
25
|
-
host = ActionMailer::Base.default_url_options[:host]
|
26
|
-
link = "http://#{host}/users/#{user.id}/password/edit" \
|
27
|
-
"?token=#{user.confirmation_token}"
|
28
|
-
|
29
|
-
email = ClearanceMailer.change_password(user)
|
30
|
-
|
31
|
-
expect(email.body.to_s).to include(link)
|
32
|
-
end
|
33
|
-
|
34
22
|
it "sets its subject" do
|
35
23
|
user = create(:user)
|
36
24
|
user.forgot_password!
|
@@ -40,25 +28,31 @@ describe ClearanceMailer do
|
|
40
28
|
expect(email.subject).to include("Change your password")
|
41
29
|
end
|
42
30
|
|
43
|
-
it "
|
31
|
+
it "has html and plain text parts" do
|
44
32
|
user = create(:user)
|
45
33
|
user.forgot_password!
|
46
34
|
|
47
35
|
email = ClearanceMailer.change_password(user)
|
48
36
|
|
49
|
-
expect(email.body).to
|
50
|
-
|
51
|
-
)
|
37
|
+
expect(email.body.parts.length).to eq 2
|
38
|
+
expect(email.text_part).to be_present
|
39
|
+
expect(email.html_part).to be_present
|
52
40
|
end
|
53
41
|
|
54
|
-
it "contains
|
42
|
+
it "contains a link to edit the password" do
|
55
43
|
user = create(:user)
|
56
44
|
user.forgot_password!
|
45
|
+
host = ActionMailer::Base.default_url_options[:host]
|
46
|
+
link = "http://#{host}/users/#{user.id}/password/edit" \
|
47
|
+
"?token=#{user.confirmation_token}"
|
57
48
|
|
58
49
|
email = ClearanceMailer.change_password(user)
|
59
50
|
|
60
|
-
expect(email.body
|
61
|
-
|
51
|
+
expect(email.text_part.body).to include(link)
|
52
|
+
expect(email.html_part.body).to include(link)
|
53
|
+
expect(email.html_part.body).to have_css(
|
54
|
+
"a",
|
55
|
+
text: I18n.t("clearance_mailer.change_password.link_text")
|
62
56
|
)
|
63
57
|
end
|
64
58
|
end
|
@@ -2,6 +2,12 @@ require "spec_helper"
|
|
2
2
|
include FakeModelWithPasswordStrategy
|
3
3
|
|
4
4
|
describe Clearance::PasswordStrategies::BCryptMigrationFromSHA1 do
|
5
|
+
around do |example|
|
6
|
+
silence_warnings do
|
7
|
+
example.run
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "#password=" do
|
6
12
|
it "encrypts the password into a BCrypt-encrypted encrypted_password" do
|
7
13
|
stub_bcrypt_password
|
@@ -2,6 +2,12 @@ require "spec_helper"
|
|
2
2
|
include FakeModelWithPasswordStrategy
|
3
3
|
|
4
4
|
describe Clearance::PasswordStrategies::Blowfish do
|
5
|
+
around do |example|
|
6
|
+
silence_warnings do
|
7
|
+
example.run
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "#password=" do
|
6
12
|
context "when the password is set" do
|
7
13
|
it "does not initialize the salt" do
|
@@ -2,6 +2,12 @@ require "spec_helper"
|
|
2
2
|
include FakeModelWithPasswordStrategy
|
3
3
|
|
4
4
|
describe Clearance::PasswordStrategies::SHA1 do
|
5
|
+
around do |example|
|
6
|
+
silence_warnings do
|
7
|
+
example.run
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
describe "#password=" do
|
6
12
|
context "when the salt is set" do
|
7
13
|
it "does not initialize the salt when assigned" do
|
data/spec/spec_helper.rb
CHANGED
@@ -26,6 +26,13 @@ RSpec.configure do |config|
|
|
26
26
|
config.mock_with :rspec do |mocks|
|
27
27
|
mocks.syntax = :expect
|
28
28
|
end
|
29
|
+
|
30
|
+
if Rails::VERSION::MAJOR >= 5
|
31
|
+
require 'rails-controller-testing'
|
32
|
+
config.include Rails::Controller::Testing::TestProcess
|
33
|
+
config.include Rails::Controller::Testing::TemplateAssertions
|
34
|
+
config.include Rails::Controller::Testing::Integration
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def restore_default_config
|
@@ -9,6 +9,10 @@ module GeneratorSpecHelpers
|
|
9
9
|
copy_to_generator_root("config", "routes.rb")
|
10
10
|
end
|
11
11
|
|
12
|
+
def provide_existing_initializer
|
13
|
+
copy_to_generator_root("config/initializers", "clearance.rb")
|
14
|
+
end
|
15
|
+
|
12
16
|
def provide_existing_application_controller
|
13
17
|
copy_to_generator_root("app/controllers", "application_controller.rb")
|
14
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Rails 5 deprecates calling HTTP action methods with positional arguments
|
2
|
+
# in favor of keyword arguments. However, the keyword argument form is only
|
3
|
+
# supported in Rails 5+. Since we support back to 3.1, we need some sort of shim
|
4
|
+
# to avoid super noisy deprecations when running tests.
|
5
|
+
module HTTPMethodShim
|
6
|
+
def get(path, params=nil, headers=nil)
|
7
|
+
super(path, params: params, headers: headers)
|
8
|
+
end
|
9
|
+
|
10
|
+
def put(path, params=nil, headers=nil)
|
11
|
+
super(path, params: params, headers: headers)
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(path, params=nil, headers=nil)
|
15
|
+
super(path, params: params, headers: headers)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if Rails::VERSION::MAJOR >= 5
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include HTTPMethodShim, type: :controller
|
22
|
+
end
|
23
|
+
end
|
data/spec/user_spec.rb
CHANGED
@@ -85,6 +85,15 @@ describe User do
|
|
85
85
|
|
86
86
|
expect(user.confirmation_token).to be_nil
|
87
87
|
end
|
88
|
+
|
89
|
+
it "sets the remember token" do
|
90
|
+
user = create(:user, :with_forgotten_password)
|
91
|
+
|
92
|
+
user.update_password("my_new_password")
|
93
|
+
|
94
|
+
user.reload
|
95
|
+
expect(user.remember_token).not_to be_nil
|
96
|
+
end
|
88
97
|
end
|
89
98
|
|
90
99
|
context "with blank password" do
|
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: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
@@ -25,7 +25,7 @@ authors:
|
|
25
25
|
autorequire:
|
26
26
|
bindir: bin
|
27
27
|
cert_chain: []
|
28
|
-
date:
|
28
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
29
29
|
dependencies:
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bcrypt
|
@@ -79,6 +79,7 @@ extra_rdoc_files:
|
|
79
79
|
files:
|
80
80
|
- ".gitignore"
|
81
81
|
- ".travis.yml"
|
82
|
+
- ".yardopts"
|
82
83
|
- Appraisals
|
83
84
|
- CONTRIBUTING.md
|
84
85
|
- Gemfile
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- app/controllers/clearance/users_controller.rb
|
94
95
|
- app/mailers/clearance_mailer.rb
|
95
96
|
- app/views/clearance_mailer/change_password.html.erb
|
97
|
+
- app/views/clearance_mailer/change_password.text.erb
|
96
98
|
- app/views/layouts/application.html.erb
|
97
99
|
- app/views/passwords/create.html.erb
|
98
100
|
- app/views/passwords/edit.html.erb
|
@@ -110,10 +112,11 @@ files:
|
|
110
112
|
- config/routes.rb
|
111
113
|
- db/migrate/20110111224543_create_clearance_users.rb
|
112
114
|
- db/schema.rb
|
113
|
-
- gemfiles/
|
114
|
-
- gemfiles/
|
115
|
-
- gemfiles/
|
116
|
-
- gemfiles/
|
115
|
+
- gemfiles/rails32.gemfile
|
116
|
+
- gemfiles/rails40.gemfile
|
117
|
+
- gemfiles/rails41.gemfile
|
118
|
+
- gemfiles/rails42.gemfile
|
119
|
+
- gemfiles/rails50.gemfile
|
117
120
|
- lib/clearance.rb
|
118
121
|
- lib/clearance/authentication.rb
|
119
122
|
- lib/clearance/authorization.rb
|
@@ -137,8 +140,10 @@ files:
|
|
137
140
|
- lib/clearance/sign_in_guard.rb
|
138
141
|
- lib/clearance/test_unit.rb
|
139
142
|
- lib/clearance/testing.rb
|
143
|
+
- lib/clearance/testing/controller_helpers.rb
|
140
144
|
- lib/clearance/testing/deny_access_matcher.rb
|
141
145
|
- lib/clearance/testing/helpers.rb
|
146
|
+
- lib/clearance/testing/view_helpers.rb
|
142
147
|
- lib/clearance/token.rb
|
143
148
|
- lib/clearance/user.rb
|
144
149
|
- lib/clearance/version.rb
|
@@ -165,6 +170,7 @@ files:
|
|
165
170
|
- spec/acceptance/clearance_installation_spec.rb
|
166
171
|
- spec/app_templates/app/controllers/application_controller.rb
|
167
172
|
- spec/app_templates/app/models/user.rb
|
173
|
+
- spec/app_templates/config/initializers/clearance.rb
|
168
174
|
- spec/app_templates/config/routes.rb
|
169
175
|
- spec/app_templates/testapp/Gemfile
|
170
176
|
- spec/app_templates/testapp/app/controllers/home_controller.rb
|
@@ -173,11 +179,13 @@ files:
|
|
173
179
|
- spec/clearance/back_door_spec.rb
|
174
180
|
- spec/clearance/constraints/signed_in_spec.rb
|
175
181
|
- spec/clearance/constraints/signed_out_spec.rb
|
182
|
+
- spec/clearance/controller_spec.rb
|
176
183
|
- spec/clearance/default_sign_in_guard_spec.rb
|
177
184
|
- spec/clearance/rack_session_spec.rb
|
178
185
|
- spec/clearance/session_spec.rb
|
179
186
|
- spec/clearance/sign_in_guard_spec.rb
|
180
|
-
- spec/clearance/testing/
|
187
|
+
- spec/clearance/testing/controller_helpers_spec.rb
|
188
|
+
- spec/clearance/testing/view_helpers_spec.rb
|
181
189
|
- spec/clearance/token_spec.rb
|
182
190
|
- spec/configuration_spec.rb
|
183
191
|
- spec/controllers/apis_controller_spec.rb
|
@@ -197,6 +205,7 @@ files:
|
|
197
205
|
- spec/generators/clearance/routes/routes_generator_spec.rb
|
198
206
|
- spec/generators/clearance/specs/specs_generator_spec.rb
|
199
207
|
- spec/generators/clearance/views/views_generator_spec.rb
|
208
|
+
- spec/helpers/helper_helpers_spec.rb
|
200
209
|
- spec/mailers/clearance_mailer_spec.rb
|
201
210
|
- spec/password_strategies/bcrypt_migration_from_sha1_spec.rb
|
202
211
|
- spec/password_strategies/bcrypt_spec.rb
|
@@ -210,8 +219,10 @@ files:
|
|
210
219
|
- spec/support/fake_model_with_password_strategy.rb
|
211
220
|
- spec/support/fake_model_without_password_strategy.rb
|
212
221
|
- spec/support/generator_spec_helpers.rb
|
222
|
+
- spec/support/http_method_shim.rb
|
213
223
|
- spec/support/request_with_remember_token.rb
|
214
224
|
- spec/user_spec.rb
|
225
|
+
- spec/views/view_helpers_spec.rb
|
215
226
|
homepage: http://github.com/thoughtbot/clearance
|
216
227
|
licenses:
|
217
228
|
- MIT
|
@@ -233,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
244
|
version: '0'
|
234
245
|
requirements: []
|
235
246
|
rubyforge_project:
|
236
|
-
rubygems_version: 2.4.
|
247
|
+
rubygems_version: 2.4.8
|
237
248
|
signing_key:
|
238
249
|
specification_version: 4
|
239
250
|
summary: Rails authentication & authorization with email & password.
|