authpwn_rails 0.18.1 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f95225e77bd6c767761b3cf3495ccb273201c74e
4
- data.tar.gz: cd28df6a7be62f693e4f238d16678c47173d720f
3
+ metadata.gz: 39e5e725d067f6fc83969be607fdbb3ec0880fd3
4
+ data.tar.gz: 3079f8aadda710eab3127f08a891c6f6d7b178eb
5
5
  SHA512:
6
- metadata.gz: fc668c5c618028caa5d320f2247161bf6d09a23b969b7f6aa04c2173d5877ea7e917e951c7a0511621cecf0b29d3aaa9c9f190e847c4ea7e67c4acd84c85f92f
7
- data.tar.gz: 925a34ef07e886f44ee7b42ef2d829d35bc6e9212f29a283a1effcef70183036cef41bcc599241b9a4947f2cf2a2cbb1b5b960ea037a262dd2cccd1fd22fbaa7
6
+ metadata.gz: 55e78b206a8a6d0709a3ef1b0cf1b6d336c0d319c0477528074c0265e10cfdc5331563dbf26ee14df68664e716c1e87d9703812c26a27f5efdd0fca90cb94020
7
+ data.tar.gz: a4a7dd595baac2da7c2f714164cd21be7975ad774caa2b070e410bd52871c9b30ce29cc12dc370655fd6f9c60797ef10983cba14f4f38e01fd2af469ca13d4f0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.18.1
1
+ 0.18.2
@@ -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.1 ruby lib
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.1"
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-17"
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.6"
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
- old_token = credentials(:jane_session_token)
148
- old_token.updated_at = Time.now - 1.year
149
- old_token.save!
150
-
151
- request.env['omniauth.auth'] = {
152
- 'provider' => @omniauth_credential.provider,
153
- 'uid' => @omniauth_credential.uid }
154
- post :omniauth, provider: @omniauth_credential.provider
155
- assert_equal @user, session_current_user, 'session'
156
- assert_redirected_to session_url
157
- assert_nil Tokens::Base.with_code(old_token.code).first,
158
- 'old session not purged'
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
- request.env['omniauth.auth'] = {
163
- 'provider' => @omniauth_credential.provider,
164
- 'uid' => 'new_user_gmail_com_uid',
165
- 'info' => { 'email' => 'new_user@gmail.com' } }
166
- post :omniauth, provider: @omniauth_credential.provider
167
- assert_not_nil session_current_user, 'session'
168
- assert_equal true, Credentials::Email.with('new_user@gmail.com').verified?,
169
- 'newly created e-mail credential not verified'
170
- assert_redirected_to session_url
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
@@ -1,2 +1,5 @@
1
1
  # Raise exceptions so we can test require / permit on params.
2
2
  ActionController::Parameters.action_on_unpermitted_parameters = :raise
3
+
4
+ # By default, CSRF protection is turned off in tests.
5
+ ActionController::Base.allow_forgery_protection = false
@@ -2,4 +2,7 @@
2
2
  class ApplicationController < ActionController::Base
3
3
  prepend_view_path File.expand_path(
4
4
  '../../../lib/authpwn_rails/generators/templates', __FILE__)
5
+
6
+ # This is necessary for testing CSRF exceptions in API calls.
7
+ protect_from_forgery with: :exception
5
8
  end
@@ -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
- request.env['omniauth.auth'] =
693
- { 'provider' => @omniauth_credential.provider,
694
- 'uid' => @omniauth_credential.uid }
695
- post :omniauth, provider: @omniauth_credential.provider
696
- assert_equal @user, assigns(:current_user), 'instance variable'
697
- assert_equal @user, session_current_user, 'session'
698
- assert_nil flash[:alert], 'no alert'
699
- assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
700
- assert_redirected_to session_url
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
- request.headers['User-Agent'] = nil
710
+ ActionController::Base.allow_forgery_protection = true
711
+ begin
712
+ request.headers['User-Agent'] = nil
705
713
 
706
- request.env['omniauth.auth'] =
707
- { 'provider' => @omniauth_credential.provider,
708
- 'uid' => @omniauth_credential.uid }
709
- post :omniauth, provider: @omniauth_credential.provider
710
- assert_equal @user, assigns(:current_user), 'instance variable'
711
- assert_equal @user, session_current_user, 'session'
712
- assert_nil flash[:alert], 'no alert'
713
- assert_nil flash[:auth_redirect_url], 'no redirect URL in flash'
714
- assert_redirected_to session_url
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
- BareSessionController.auto_purge_sessions = true
719
- old_token = credentials(:jane_session_token)
720
- old_token.updated_at = Time.now - 1.year
721
- old_token.save!
722
- request.env['omniauth.auth'] =
723
- { 'provider' => @omniauth_credential.provider,
724
- 'uid' => @omniauth_credential.uid }
725
- post :omniauth, provider: @omniauth_credential.provider
726
- assert_equal @user, session_current_user, 'session'
727
- assert_nil Tokens::Base.with_code(old_token.code).first,
728
- 'old session not purged'
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
- BareSessionController.auto_purge_sessions = false
733
- old_token = credentials(:jane_session_token)
734
- old_token.updated_at = Time.now - 1.year
735
- old_token.save!
736
- request.env['omniauth.auth'] =
737
- { 'provider' => @omniauth_credential.provider,
738
- 'uid' => @omniauth_credential.uid }
739
- post :omniauth, provider: @omniauth_credential.provider
740
- assert_equal @user, session_current_user, 'session'
741
- assert_equal old_token, Tokens::Base.with_code(old_token.code).first,
742
- 'old session purged'
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
- BareSessionController.auto_purge_sessions = true
747
- old_token = credentials(:jane_session_token)
748
- old_token.updated_at = Time.now - 1.year
749
- old_token.save!
750
- request.env['omniauth.auth'] =
751
- { 'provider' => @omniauth_credential.provider, 'uid' => 'fail' }
752
- post :omniauth, provider: @omniauth_credential.provider
753
- assert_nil session_current_user, 'session'
754
- assert_equal old_token, Tokens::Base.with_code(old_token.code).first,
755
- 'old session purged'
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
- request.env['omniauth.auth'] =
760
- { 'provider' => @omniauth_credential.provider,
761
- 'uid' => @omniauth_credential.uid }
762
- with_blocked_credential @omniauth_credential do
763
- post :omniauth, provider: @omniauth_credential.provider
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
- omniauth_hash = { 'provider' => 'fail', 'uid' => 'fail' }
774
- request.env['omniauth.auth'] = omniauth_hash
775
- Credentials::OmniAuthUid.expects(:authenticate).at_least_once.
776
- with(omniauth_hash).returns @omniauth_credential.user
777
- post :omniauth, provider: @omniauth_credential.provider
778
- assert_equal @user, assigns(:current_user), 'instance variable'
779
- assert_equal @user, session_current_user, 'session'
780
- assert_redirected_to session_url
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.1
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-17 00:00:00.000000000 Z
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.6
318
+ rubygems_version: 2.4.5
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: User authentication for Rails 4 applications.