authenticate 0.7.2 → 0.7.3
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/.travis.yml +3 -0
- data/Appraisals +5 -1
- data/CHANGELOG.md +13 -0
- data/Rakefile +8 -0
- data/app/controllers/authenticate/passwords_controller.rb +5 -9
- data/authenticate.gemspec +2 -2
- data/gemfiles/5.2.gemfile +7 -0
- data/lib/authenticate/controller.rb +3 -3
- data/lib/authenticate/lifecycle.rb +2 -2
- data/lib/authenticate/session.rb +2 -1
- data/lib/authenticate/version.rb +1 -1
- data/spec/dummy/config/application.rb +5 -0
- data/spec/factories/users.rb +1 -1
- data/spec/requests/csrf_rotation_spec.rb +1 -0
- data/spec/requests/session_key_spec.rb +4 -0
- data/spec/spec_helper.rb +3 -4
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 064f6cc3d53977f074f3d50a8bd844741e21061d
|
4
|
+
data.tar.gz: 6158456020cb666d65d1d0d2fb03db0994e58311
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0c0df19972e607c36030c29f08b393fb3da6338348c7130ced5bcb578b3b577758a518b768e414573fcc82ee5b5ac7afc87d563a51f6ef15ff1c533445fa936
|
7
|
+
data.tar.gz: 3319a94b72c651f3add224978dc1f7840670a992c7c539a93059de2df9478d6e78ea9fb3c20ae87eb743d97f6f89cba2395ddce373c1324609d64390d4171759
|
data/.travis.yml
CHANGED
@@ -13,6 +13,7 @@ gemfile:
|
|
13
13
|
- gemfiles/4.2.gemfile
|
14
14
|
- gemfiles/5.0.gemfile
|
15
15
|
- gemfiles/5.1.gemfile
|
16
|
+
- gemfiles/5.2.gemfile
|
16
17
|
|
17
18
|
|
18
19
|
matrix:
|
@@ -21,6 +22,8 @@ matrix:
|
|
21
22
|
gemfile: gemfiles/5.0.gemfile
|
22
23
|
- rvm: 2.1.8
|
23
24
|
gemfile: gemfiles/5.1.gemfile
|
25
|
+
- rvm: 2.1.8
|
26
|
+
gemfile: gemfiles/5.2.gemfile
|
24
27
|
- rvm: 2.4.1
|
25
28
|
gemfile: gemfiles/4.2.gemfile
|
26
29
|
|
data/Appraisals
CHANGED
@@ -4,7 +4,7 @@ if RUBY_VERSION < "2.4.0"
|
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
if RUBY_VERSION >= "2.2.
|
7
|
+
if RUBY_VERSION >= "2.2.2"
|
8
8
|
appraise "5.0" do
|
9
9
|
gem "rails", "~> 5.0.0"
|
10
10
|
end
|
@@ -12,5 +12,9 @@ if RUBY_VERSION >= "2.2.0"
|
|
12
12
|
appraise "5.1" do
|
13
13
|
gem "rails", "~> 5.1"
|
14
14
|
end
|
15
|
+
|
16
|
+
appraise "5.2" do
|
17
|
+
gem "rails", "~> 5.2"
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
# Authenticate Changelog
|
2
2
|
|
3
3
|
|
4
|
+
## [0.7.3] - June 7, 2018
|
5
|
+
|
6
|
+
### Support for rails 5.2
|
7
|
+
- added rails 5.2 support to gemspec
|
8
|
+
- added rails 5.2 to Appraisals, .travis.yml, gemfiles
|
9
|
+
- added `sqlite3.represent_boolean_as_integer = true` to dummy application config
|
10
|
+
- bumped authenticate version
|
11
|
+
- update request specs, looks for 302 after login
|
12
|
+
- added build and release tasks to Rakefile
|
13
|
+
|
14
|
+
[0.7.3]: https://github.com/tomichj/authenticate/compare/v0.7.2...v0.7.3
|
15
|
+
|
16
|
+
|
4
17
|
## [0.7.2] - June 22, 2017
|
5
18
|
|
6
19
|
### API change
|
data/Rakefile
CHANGED
@@ -16,3 +16,11 @@ RSpec::Core::RakeTask.new(:spec)
|
|
16
16
|
|
17
17
|
desc 'Run all specs in spec directory (excluding plugin specs)'
|
18
18
|
task default: :spec
|
19
|
+
|
20
|
+
task :build do
|
21
|
+
system "gem build authenticate.gemspec"
|
22
|
+
end
|
23
|
+
|
24
|
+
task release: :build do
|
25
|
+
system "gem push authenticate-#{Authenticate::VERSION}"
|
26
|
+
end
|
@@ -6,14 +6,13 @@ class Authenticate::PasswordsController < Authenticate::AuthenticateController
|
|
6
6
|
before_action :ensure_existing_user, only: [:edit, :update]
|
7
7
|
|
8
8
|
# Display screen to request a password change email.
|
9
|
+
#
|
9
10
|
# GET /users/passwords/new
|
10
11
|
def new
|
11
12
|
render template: 'passwords/new'
|
12
13
|
end
|
13
14
|
|
14
15
|
# Send password change email.
|
15
|
-
#
|
16
|
-
# POST /users/password
|
17
16
|
def create
|
18
17
|
if (user = find_user_for_create)
|
19
18
|
user.forgot_password!
|
@@ -22,12 +21,12 @@ class Authenticate::PasswordsController < Authenticate::AuthenticateController
|
|
22
21
|
redirect_to sign_in_path, notice: flash_create_description
|
23
22
|
end
|
24
23
|
|
25
|
-
#
|
24
|
+
# Enter a new password.
|
26
25
|
#
|
27
|
-
# A get with the token in the url is expected:
|
26
|
+
# A get with the token in the url is expected, for example:
|
28
27
|
# GET /users/passwords/3/edit?token=abcdef
|
29
28
|
#
|
30
|
-
#
|
29
|
+
# Results in a redirect with the token removed from the url & copied to the session:
|
31
30
|
# GET /users/passwords/3/edit
|
32
31
|
#
|
33
32
|
def edit
|
@@ -35,7 +34,7 @@ class Authenticate::PasswordsController < Authenticate::AuthenticateController
|
|
35
34
|
|
36
35
|
if params[:token]
|
37
36
|
session[:password_reset_token] = params[:token]
|
38
|
-
redirect_to
|
37
|
+
redirect_to url_for
|
39
38
|
elsif !@user.reset_password_period_valid?
|
40
39
|
redirect_to sign_in_path, notice: flash_failure_token_expired
|
41
40
|
else
|
@@ -43,9 +42,6 @@ class Authenticate::PasswordsController < Authenticate::AuthenticateController
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
# Save the new password entered in #edit.
|
47
|
-
#
|
48
|
-
# PUT /users/passwords/3/
|
49
45
|
def update
|
50
46
|
@user = find_user_for_update
|
51
47
|
|
data/authenticate.gemspec
CHANGED
@@ -23,9 +23,9 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.add_dependency 'bcrypt'
|
25
25
|
s.add_dependency 'email_validator', '~> 1.6'
|
26
|
-
s.add_dependency 'rails', '>= 4.0', '< 5.
|
26
|
+
s.add_dependency 'rails', '>= 4.0', '< 5.3'
|
27
27
|
|
28
|
-
s.add_development_dependency '
|
28
|
+
s.add_development_dependency 'factory_bot', '~> 4.8.2'
|
29
29
|
s.add_development_dependency 'rspec-rails', '~> 3.6'
|
30
30
|
s.add_development_dependency 'pry', '~> 0.10'
|
31
31
|
s.add_development_dependency 'sqlite3', '~> 1.3'
|
@@ -16,7 +16,7 @@ module Authenticate
|
|
16
16
|
# * logout - log a user out, invalidating their Authenticate session.
|
17
17
|
#
|
18
18
|
# Action/Filter:
|
19
|
-
# *
|
19
|
+
# * require_login - restrict access to authenticated users, often from ApplicationController
|
20
20
|
#
|
21
21
|
# Helpers, used anywhere:
|
22
22
|
# * current_user - get the currently logged in user
|
@@ -129,7 +129,7 @@ module Authenticate
|
|
129
129
|
is_a?(Authenticate::AuthenticateController)
|
130
130
|
end
|
131
131
|
|
132
|
-
# The old API.
|
132
|
+
# The old API. DEPRECATED, use #require_login instead.
|
133
133
|
#
|
134
134
|
# todo: remove in a future version.
|
135
135
|
def require_authentication
|
@@ -138,7 +138,7 @@ module Authenticate
|
|
138
138
|
require_login
|
139
139
|
end
|
140
140
|
|
141
|
-
# The old API.
|
141
|
+
# The old API. DEPRECATED, use #logged_in? instead.
|
142
142
|
#
|
143
143
|
# todo: remove in a future version.
|
144
144
|
def authenticated?
|
@@ -62,7 +62,7 @@ module Authenticate
|
|
62
62
|
# Example:
|
63
63
|
# Authenticate.lifecycle.run_callbacks(:after_set_user, @current_user, self, { event: :authentication })
|
64
64
|
#
|
65
|
-
def run_callbacks(kind, *args) # args - |user, session, opts|
|
65
|
+
def run_callbacks(kind, user, session, *args) # args - |user, session, opts|
|
66
66
|
# Last callback arg MUST be a Hash
|
67
67
|
options = args.last
|
68
68
|
send("#{kind}_callbacks").each do |callback, conditions| # each callback has 'conditions' stored with it
|
@@ -70,7 +70,7 @@ module Authenticate
|
|
70
70
|
invalid = conditions.find do |key, value|
|
71
71
|
value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
|
72
72
|
end
|
73
|
-
callback.call(*args) unless invalid
|
73
|
+
callback.call(user, session, *args) unless invalid
|
74
74
|
end
|
75
75
|
nil
|
76
76
|
end
|
data/lib/authenticate/session.rb
CHANGED
@@ -19,6 +19,7 @@ module Authenticate
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Finish user login process, *after* the user has been authenticated.
|
22
|
+
# The user is authenticated by Authenticate::Controller#authenticate.
|
22
23
|
#
|
23
24
|
# Called when user creates an account or signs back into the app.
|
24
25
|
# Runs all configured callbacks, checking for login failure.
|
@@ -81,7 +82,7 @@ module Authenticate
|
|
81
82
|
# nuke notion of current_user
|
82
83
|
@current_user = nil
|
83
84
|
|
84
|
-
#
|
85
|
+
# nuke session_token cookie from the client browser
|
85
86
|
@cookies.delete cookie_name
|
86
87
|
end
|
87
88
|
|
data/lib/authenticate/version.rb
CHANGED
@@ -26,3 +26,8 @@ module Dummy
|
|
26
26
|
end
|
27
27
|
|
28
28
|
Rails.application.routes.default_url_options[:host] = 'localhost:3000'
|
29
|
+
|
30
|
+
if Rails.application.config.active_record.sqlite3.respond_to? :represent_boolean_as_integer
|
31
|
+
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
|
32
|
+
end
|
33
|
+
|
data/spec/factories/users.rb
CHANGED
@@ -23,6 +23,7 @@ describe 'CSRF rotation' do
|
|
23
23
|
do_post session_path, params: { **session_params }
|
24
24
|
|
25
25
|
# expect that we now have a new csrf token
|
26
|
+
expect(response).to have_http_status(302)
|
26
27
|
expect(csrf_token).not_to eq original_token
|
27
28
|
expect(csrf_token).to be_present
|
28
29
|
end
|
@@ -7,6 +7,10 @@ describe 'session key assignment' do
|
|
7
7
|
do_post session_path, params: { session: { email: @user.email, password: @user.password } }
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'redirects after login' do
|
11
|
+
expect(response).to have_http_status(302)
|
12
|
+
end
|
13
|
+
|
10
14
|
it 'sets user session token' do
|
11
15
|
@user.reload
|
12
16
|
expect(@user.session_token).to_not be_nil
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ require 'rspec/rails'
|
|
12
12
|
require 'capybara/rails'
|
13
13
|
require 'capybara/rspec'
|
14
14
|
require 'database_cleaner'
|
15
|
-
require '
|
15
|
+
require 'factory_bot'
|
16
16
|
require 'timecop'
|
17
17
|
|
18
18
|
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
@@ -20,7 +20,7 @@ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
|
20
20
|
Rails.backtrace_cleaner.remove_silencers!
|
21
21
|
DatabaseCleaner.strategy = :truncation
|
22
22
|
|
23
|
-
# Load factory
|
23
|
+
# Load factory bot factories.
|
24
24
|
Dir[File.join(File.dirname(__FILE__), 'factories/**/*.rb')].each { |f| require f }
|
25
25
|
|
26
26
|
# Build test database in spec/dummy/db. There's probably a better way to do this.
|
@@ -35,7 +35,7 @@ if ActiveRecord::VERSION::STRING >= '4.2' && ActiveRecord::VERSION::STRING < '5.
|
|
35
35
|
end
|
36
36
|
|
37
37
|
RSpec.configure do |config|
|
38
|
-
config.include
|
38
|
+
config.include FactoryBot::Syntax::Methods
|
39
39
|
config.infer_spec_type_from_file_location!
|
40
40
|
config.order = :random
|
41
41
|
config.use_transactional_fixtures = true
|
@@ -54,4 +54,3 @@ RSpec.configure do |config|
|
|
54
54
|
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authenticate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Tomich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -47,7 +47,7 @@ dependencies:
|
|
47
47
|
version: '4.0'
|
48
48
|
- - "<"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '5.
|
50
|
+
version: '5.3'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -57,21 +57,21 @@ dependencies:
|
|
57
57
|
version: '4.0'
|
58
58
|
- - "<"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '5.
|
60
|
+
version: '5.3'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: factory_bot
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
67
|
+
version: 4.8.2
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 4.8.2
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rspec-rails
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- gemfiles/4.2.gemfile
|
228
228
|
- gemfiles/5.0.gemfile
|
229
229
|
- gemfiles/5.1.gemfile
|
230
|
+
- gemfiles/5.2.gemfile
|
230
231
|
- lib/authenticate.rb
|
231
232
|
- lib/authenticate/callbacks/authenticatable.rb
|
232
233
|
- lib/authenticate/callbacks/brute_force.rb
|