omniauth-rails_csrf_protection 2.0.0 → 2.0.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 156f0458f77fc7be417f9d4080ef3ca1c078b3ec97d2f5a260331f0ca7117ac8
|
|
4
|
+
data.tar.gz: 545b29f8d28c47803f9367bfcaccdcd412afd2d7e78bb571f46ef87b53ef6f14
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e23fceeb38d067b51e3a6751b194f9c47bcbb706919aa16024bf4e5f568c2168403c9346f0e4202c3c1dd54db6b4f46e20c70aaa3ac45e74852f5d4e2aaedf53
|
|
7
|
+
data.tar.gz: c4daf8660e73c639a123e8246c3e86583b951d6f6b546590b4467981fc52952e014e08f7092c3a2c3c164f88fdc218c52f2d77331f7d5fd0182f1375a5f2d94c
|
|
@@ -29,9 +29,16 @@ module OmniAuth
|
|
|
29
29
|
def config
|
|
30
30
|
self.class.config
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
# For Rails 8.1+, includes this module after `config` is setup.
|
|
34
|
+
include ActionController::RequestForgeryProtection
|
|
32
35
|
else
|
|
33
36
|
include ActiveSupport::Configurable
|
|
34
37
|
|
|
38
|
+
# For Rails < 8.1, includes this module before delegation setup.
|
|
39
|
+
# Otherwise, `config` will be empty, and the delegation will fail.
|
|
40
|
+
include ActionController::RequestForgeryProtection
|
|
41
|
+
|
|
35
42
|
# `ActionController::RequestForgeryProtection` contains a few
|
|
36
43
|
# configurable options. As we want to make sure that our configuration is
|
|
37
44
|
# the same as what being set in `ActionController::Base`, we should make
|
|
@@ -44,9 +51,6 @@ module OmniAuth
|
|
|
44
51
|
end
|
|
45
52
|
end
|
|
46
53
|
|
|
47
|
-
# Include this module only after we've prepared the configuration
|
|
48
|
-
include ActionController::RequestForgeryProtection
|
|
49
|
-
|
|
50
54
|
def call(env)
|
|
51
55
|
dup._call(env)
|
|
52
56
|
end
|
data/test/application_test.rb
CHANGED
|
@@ -13,14 +13,14 @@ class ApplicationTest < Minitest::Test
|
|
|
13
13
|
post "/auth/developer"
|
|
14
14
|
follow_redirect!
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
assert_equal "ActionController::InvalidAuthenticityToken", last_response.body
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def test_request_phrase_with_bad_token_via_post
|
|
20
20
|
post "/auth/developer", authenticity_token: "BAD_TOKEN"
|
|
21
21
|
follow_redirect!
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
assert_equal "ActionController::InvalidAuthenticityToken", last_response.body
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def test_request_phrase_with_correct_token_via_post
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
require "capybara/rails"
|
|
3
|
+
require "capybara/minitest"
|
|
4
|
+
|
|
5
|
+
class IntegrationTest < ActionDispatch::IntegrationTest
|
|
6
|
+
include Capybara::DSL
|
|
7
|
+
include Capybara::Minitest::Assertions
|
|
8
|
+
|
|
9
|
+
# We are using this `:per_form_csrf_tokens` as a way to test that we have
|
|
10
|
+
# setup method delegation properly to prevent regression, as Railtie sets
|
|
11
|
+
# this configuration to true afterward and causes them to be out-of-sync.
|
|
12
|
+
setup do
|
|
13
|
+
@original_per_form_csrf_tokens = \
|
|
14
|
+
ActionController::Base.config[:per_form_csrf_tokens]
|
|
15
|
+
ActionController::Base.config[:per_form_csrf_tokens] = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
teardown do
|
|
19
|
+
ActionController::Base.config[:per_form_csrf_tokens] = \
|
|
20
|
+
@original_per_form_csrf_tokens
|
|
21
|
+
|
|
22
|
+
Capybara.reset_sessions!
|
|
23
|
+
Capybara.use_default_driver
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_request_phrase
|
|
27
|
+
visit sign_in_path
|
|
28
|
+
click_on "Sign in"
|
|
29
|
+
|
|
30
|
+
refute page.has_content?("ActionController::InvalidAuthenticityToken")
|
|
31
|
+
|
|
32
|
+
fill_in "Name", with: "Kagari Mimi"
|
|
33
|
+
fill_in "Email", with: "mimi@example.com"
|
|
34
|
+
click_on "Sign In"
|
|
35
|
+
|
|
36
|
+
assert page.has_content?("Hello Kagari Mimi (mimi@example.com)!")
|
|
37
|
+
end
|
|
38
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
2
2
|
|
|
3
3
|
# Simple Rails application template, based on Rails issue template
|
|
4
|
-
# https://github.com/rails/rails/blob/
|
|
4
|
+
# https://github.com/rails/rails/blob/main/guides/bug_report_templates/action_controller.rb
|
|
5
5
|
|
|
6
6
|
# Helper method to silence warnings from bundler/inline
|
|
7
7
|
def silence_warnings
|
|
@@ -27,9 +27,11 @@ silence_warnings do
|
|
|
27
27
|
|
|
28
28
|
if RUBY_VERSION >= "3.4"
|
|
29
29
|
gem "bigdecimal"
|
|
30
|
+
gem "drb"
|
|
30
31
|
gem "mutex_m"
|
|
31
32
|
end
|
|
32
33
|
|
|
34
|
+
gem "capybara"
|
|
33
35
|
gem "omniauth"
|
|
34
36
|
gem "omniauth-rails_csrf_protection", path: File.expand_path("..", __dir__)
|
|
35
37
|
end
|
|
@@ -64,9 +66,7 @@ class TestApp < Rails::Application
|
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
# Silence the deprecation warning in Rails 8.0.x
|
|
67
|
-
if
|
|
68
|
-
Rails.version >= Gem::Version.new("8.0.x") &&
|
|
69
|
-
Rails.version < Gem::Version.new("8.1")
|
|
69
|
+
if Gem::Requirement.new("~> 8.0.x").satisfied_by?(Rails.gem_version)
|
|
70
70
|
config.active_support.to_time_preserves_timezone = :zone
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -75,7 +75,10 @@ class TestApp < Rails::Application
|
|
|
75
75
|
|
|
76
76
|
# Define our custom routes. This needs to be called after initialize!
|
|
77
77
|
routes.draw do
|
|
78
|
+
get "sign_in" => "application#sign_in"
|
|
78
79
|
get "token" => "application#token"
|
|
80
|
+
get "auth/failure" => "application#failure"
|
|
81
|
+
match "auth/developer/callback" => "application#callback", :via => [:get, :post]
|
|
79
82
|
end
|
|
80
83
|
end
|
|
81
84
|
|
|
@@ -84,4 +87,18 @@ class ApplicationController < ActionController::Base
|
|
|
84
87
|
def token
|
|
85
88
|
render plain: form_authenticity_token
|
|
86
89
|
end
|
|
90
|
+
|
|
91
|
+
def sign_in
|
|
92
|
+
render inline: <<~ERB
|
|
93
|
+
<%= button_to "Sign in", "/auth/developer", method: :post %>
|
|
94
|
+
ERB
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def failure
|
|
98
|
+
render plain: params[:message]
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def callback
|
|
102
|
+
render plain: "Hello #{params[:name]} (#{params[:email]})!"
|
|
103
|
+
end
|
|
87
104
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-rails_csrf_protection
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cookpad Inc.
|
|
@@ -52,7 +52,7 @@ dependencies:
|
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '0'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
55
|
+
name: capybara
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
@@ -66,7 +66,7 @@ dependencies:
|
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '0'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name:
|
|
69
|
+
name: minitest
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - ">="
|
|
@@ -79,6 +79,20 @@ dependencies:
|
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
81
|
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rails
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 7.2.0
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 7.2.0
|
|
82
96
|
- !ruby/object:Gem::Dependency
|
|
83
97
|
name: rake
|
|
84
98
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,6 +125,7 @@ files:
|
|
|
111
125
|
- lib/omniauth/rails_csrf_protection/token_verifier.rb
|
|
112
126
|
- lib/omniauth/rails_csrf_protection/version.rb
|
|
113
127
|
- test/application_test.rb
|
|
128
|
+
- test/integration_test.rb
|
|
114
129
|
- test/test_helper.rb
|
|
115
130
|
homepage: https://github.com/cookpad/omniauth-rails_csrf_protection
|
|
116
131
|
licenses:
|
|
@@ -135,4 +150,5 @@ specification_version: 4
|
|
|
135
150
|
summary: Provides CSRF protection on OmniAuth request endpoint on Rails application.
|
|
136
151
|
test_files:
|
|
137
152
|
- test/application_test.rb
|
|
153
|
+
- test/integration_test.rb
|
|
138
154
|
- test/test_helper.rb
|