authpwn_rails 0.18.1 → 0.18.2
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/VERSION +1 -1
- data/authpwn_rails.gemspec +4 -4
- data/lib/authpwn_rails/generators/templates/session_controller_test.rb +31 -21
- data/lib/authpwn_rails/session_controller.rb +3 -0
- data/test/helpers/action_controller.rb +3 -0
- data/test/helpers/application_controller.rb +3 -0
- data/test/session_controller_api_test.rb +105 -69
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39e5e725d067f6fc83969be607fdbb3ec0880fd3
|
4
|
+
data.tar.gz: 3079f8aadda710eab3127f08a891c6f6d7b178eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55e78b206a8a6d0709a3ef1b0cf1b6d336c0d319c0477528074c0265e10cfdc5331563dbf26ee14df68664e716c1e87d9703812c26a27f5efdd0fca90cb94020
|
7
|
+
data.tar.gz: a4a7dd595baac2da7c2f714164cd21be7975ad774caa2b070e410bd52871c9b30ce29cc12dc370655fd6f9c60797ef10983cba14f4f38e01fd2af469ca13d4f0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.18.
|
1
|
+
0.18.2
|
data/authpwn_rails.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: authpwn_rails 0.18.
|
5
|
+
# stub: authpwn_rails 0.18.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "authpwn_rails"
|
9
|
-
s.version = "0.18.
|
9
|
+
s.version = "0.18.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Victor Costan"]
|
14
|
-
s.date = "2015-06-
|
14
|
+
s.date = "2015-06-21"
|
15
15
|
s.description = "Works with Facebook."
|
16
16
|
s.email = "victor@costan.us"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -131,7 +131,7 @@ Gem::Specification.new do |s|
|
|
131
131
|
]
|
132
132
|
s.homepage = "http://github.com/pwnall/authpwn_rails"
|
133
133
|
s.licenses = ["MIT"]
|
134
|
-
s.rubygems_version = "2.4.
|
134
|
+
s.rubygems_version = "2.4.5"
|
135
135
|
s.summary = "User authentication for Rails 4 applications."
|
136
136
|
|
137
137
|
if s.respond_to? :specification_version then
|
@@ -144,29 +144,39 @@ class SessionControllerTest < ActionController::TestCase
|
|
144
144
|
end
|
145
145
|
|
146
146
|
test "OmniAuth login via developer strategy and good account" do
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
147
|
+
ActionController::Base.allow_forgery_protection = true
|
148
|
+
begin
|
149
|
+
old_token = credentials(:jane_session_token)
|
150
|
+
old_token.updated_at = Time.now - 1.year
|
151
|
+
old_token.save!
|
152
|
+
|
153
|
+
request.env['omniauth.auth'] = {
|
154
|
+
'provider' => @omniauth_credential.provider,
|
155
|
+
'uid' => @omniauth_credential.uid }
|
156
|
+
post :omniauth, provider: @omniauth_credential.provider
|
157
|
+
assert_equal @user, session_current_user, 'session'
|
158
|
+
assert_redirected_to session_url
|
159
|
+
assert_nil Tokens::Base.with_code(old_token.code).first,
|
160
|
+
'old session not purged'
|
161
|
+
ensure
|
162
|
+
ActionController::Base.allow_forgery_protection = false
|
163
|
+
end
|
159
164
|
end
|
160
165
|
|
161
166
|
test "OmniAuth login via developer strategy and new account" do
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
167
|
+
ActionController::Base.allow_forgery_protection = true
|
168
|
+
begin
|
169
|
+
request.env['omniauth.auth'] = {
|
170
|
+
'provider' => @omniauth_credential.provider,
|
171
|
+
'uid' => 'new_user_gmail_com_uid',
|
172
|
+
'info' => { 'email' => 'new_user@gmail.com' } }
|
173
|
+
post :omniauth, provider: @omniauth_credential.provider
|
174
|
+
assert_not_nil session_current_user, 'session'
|
175
|
+
assert_equal true, Credentials::Email.with('new_user@gmail.com').verified?,
|
176
|
+
'newly created e-mail credential not verified'
|
177
|
+
assert_redirected_to session_url
|
178
|
+
ensure
|
179
|
+
ActionController::Base.allow_forgery_protection = false
|
180
|
+
end
|
171
181
|
end
|
172
182
|
end
|
@@ -14,6 +14,9 @@ module SessionController
|
|
14
14
|
skip_filter :authenticate_using_session
|
15
15
|
authenticates_using_session except: [:create, :reset_password, :token]
|
16
16
|
|
17
|
+
# NOTE: The Omniauth callback uses POST in some cases.
|
18
|
+
skip_filter :verify_authenticity_token, only: [:omniauth]
|
19
|
+
|
17
20
|
# If set, every successful login will cause a database purge.
|
18
21
|
class_attribute :auto_purge_sessions
|
19
22
|
self.auto_purge_sessions = true
|
@@ -689,95 +689,131 @@ class SessionControllerApiTest < ActionController::TestCase
|
|
689
689
|
end
|
690
690
|
|
691
691
|
test "omniauth logs in with good account details" do
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
692
|
+
ActionController::Base.allow_forgery_protection = true
|
693
|
+
begin
|
694
|
+
|
695
|
+
request.env['omniauth.auth'] =
|
696
|
+
{ 'provider' => @omniauth_credential.provider,
|
697
|
+
'uid' => @omniauth_credential.uid }
|
698
|
+
post :omniauth, provider: @omniauth_credential.provider
|
699
|
+
assert_equal @user, assigns(:current_user), 'instance variable'
|
700
|
+
assert_equal @user, session_current_user, 'session'
|
701
|
+
assert_nil flash[:alert], 'no alert'
|
702
|
+
assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
|
703
|
+
assert_redirected_to session_url
|
704
|
+
ensure
|
705
|
+
ActionController::Base.allow_forgery_protection = false
|
706
|
+
end
|
701
707
|
end
|
702
708
|
|
703
709
|
test "omniauth logs in with good account details and no User-Agent" do
|
704
|
-
|
710
|
+
ActionController::Base.allow_forgery_protection = true
|
711
|
+
begin
|
712
|
+
request.headers['User-Agent'] = nil
|
705
713
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
714
|
+
request.env['omniauth.auth'] =
|
715
|
+
{ 'provider' => @omniauth_credential.provider,
|
716
|
+
'uid' => @omniauth_credential.uid }
|
717
|
+
post :omniauth, provider: @omniauth_credential.provider
|
718
|
+
assert_equal @user, assigns(:current_user), 'instance variable'
|
719
|
+
assert_equal @user, session_current_user, 'session'
|
720
|
+
assert_nil flash[:alert], 'no alert'
|
721
|
+
assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
|
722
|
+
assert_redirected_to session_url
|
723
|
+
ensure
|
724
|
+
ActionController::Base.allow_forgery_protection = false
|
725
|
+
end
|
715
726
|
end
|
716
727
|
|
717
728
|
test "omniauth purges sessions when logging in" do
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
+
ActionController::Base.allow_forgery_protection = true
|
730
|
+
begin
|
731
|
+
BareSessionController.auto_purge_sessions = true
|
732
|
+
old_token = credentials(:jane_session_token)
|
733
|
+
old_token.updated_at = Time.now - 1.year
|
734
|
+
old_token.save!
|
735
|
+
request.env['omniauth.auth'] =
|
736
|
+
{ 'provider' => @omniauth_credential.provider,
|
737
|
+
'uid' => @omniauth_credential.uid }
|
738
|
+
post :omniauth, provider: @omniauth_credential.provider
|
739
|
+
assert_equal @user, session_current_user, 'session'
|
740
|
+
assert_nil Tokens::Base.with_code(old_token.code).first,
|
741
|
+
'old session not purged'
|
742
|
+
ensure
|
743
|
+
ActionController::Base.allow_forgery_protection = false
|
744
|
+
end
|
729
745
|
end
|
730
746
|
|
731
747
|
test "omniauth does not purge sessions if auto_purge_sessions is false" do
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
748
|
+
ActionController::Base.allow_forgery_protection = true
|
749
|
+
begin
|
750
|
+
BareSessionController.auto_purge_sessions = false
|
751
|
+
old_token = credentials(:jane_session_token)
|
752
|
+
old_token.updated_at = Time.now - 1.year
|
753
|
+
old_token.save!
|
754
|
+
request.env['omniauth.auth'] =
|
755
|
+
{ 'provider' => @omniauth_credential.provider,
|
756
|
+
'uid' => @omniauth_credential.uid }
|
757
|
+
post :omniauth, provider: @omniauth_credential.provider
|
758
|
+
assert_equal @user, session_current_user, 'session'
|
759
|
+
assert_equal old_token, Tokens::Base.with_code(old_token.code).first,
|
760
|
+
'old session purged'
|
761
|
+
ensure
|
762
|
+
ActionController::Base.allow_forgery_protection = false
|
763
|
+
end
|
743
764
|
end
|
744
765
|
|
745
766
|
test "omniauth does not purge sessions if not logged in" do
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
767
|
+
ActionController::Base.allow_forgery_protection = true
|
768
|
+
begin
|
769
|
+
BareSessionController.auto_purge_sessions = true
|
770
|
+
old_token = credentials(:jane_session_token)
|
771
|
+
old_token.updated_at = Time.now - 1.year
|
772
|
+
old_token.save!
|
773
|
+
request.env['omniauth.auth'] =
|
774
|
+
{ 'provider' => @omniauth_credential.provider, 'uid' => 'fail' }
|
775
|
+
post :omniauth, provider: @omniauth_credential.provider
|
776
|
+
assert_nil session_current_user, 'session'
|
777
|
+
assert_equal old_token, Tokens::Base.with_code(old_token.code).first,
|
778
|
+
'old session purged'
|
779
|
+
ensure
|
780
|
+
ActionController::Base.allow_forgery_protection = false
|
781
|
+
end
|
756
782
|
end
|
757
783
|
|
758
784
|
test "omniauth does not log in blocked accounts" do
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
785
|
+
ActionController::Base.allow_forgery_protection = true
|
786
|
+
begin
|
787
|
+
request.env['omniauth.auth'] =
|
788
|
+
{ 'provider' => @omniauth_credential.provider,
|
789
|
+
'uid' => @omniauth_credential.uid }
|
790
|
+
with_blocked_credential @omniauth_credential do
|
791
|
+
post :omniauth, provider: @omniauth_credential.provider
|
792
|
+
end
|
793
|
+
assert_redirected_to new_session_url
|
794
|
+
assert_nil assigns(:current_user), 'instance variable'
|
795
|
+
assert_nil session_current_user, 'session'
|
796
|
+
assert_match(/ blocked/, flash[:alert])
|
797
|
+
assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
|
798
|
+
ensure
|
799
|
+
ActionController::Base.allow_forgery_protection = false
|
764
800
|
end
|
765
|
-
assert_redirected_to new_session_url
|
766
|
-
assert_nil assigns(:current_user), 'instance variable'
|
767
|
-
assert_nil session_current_user, 'session'
|
768
|
-
assert_match(/ blocked/, flash[:alert])
|
769
|
-
assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
|
770
801
|
end
|
771
802
|
|
772
803
|
test "omniauth uses Credentials::OmniAuthUid.authenticate" do
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
804
|
+
ActionController::Base.allow_forgery_protection = true
|
805
|
+
begin
|
806
|
+
omniauth_hash = { 'provider' => 'fail', 'uid' => 'fail' }
|
807
|
+
request.env['omniauth.auth'] = omniauth_hash
|
808
|
+
Credentials::OmniAuthUid.expects(:authenticate).at_least_once.
|
809
|
+
with(omniauth_hash).returns @omniauth_credential.user
|
810
|
+
post :omniauth, provider: @omniauth_credential.provider
|
811
|
+
assert_equal @user, assigns(:current_user), 'instance variable'
|
812
|
+
assert_equal @user, session_current_user, 'session'
|
813
|
+
assert_redirected_to session_url
|
814
|
+
ensure
|
815
|
+
ActionController::Base.allow_forgery_protection = false
|
816
|
+
end
|
781
817
|
end
|
782
818
|
|
783
819
|
test "auth_controller? is true" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authpwn_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
version: '0'
|
316
316
|
requirements: []
|
317
317
|
rubyforge_project:
|
318
|
-
rubygems_version: 2.4.
|
318
|
+
rubygems_version: 2.4.5
|
319
319
|
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: User authentication for Rails 4 applications.
|