omniauth-rails_csrf_protection 0.1.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: bbf4c1c69045d3b8841a8e002fad5367924f1d3656bb030473da95ec61681878
4
- data.tar.gz: 57f056afa7f51d2722129715a074aa19afeac9acd58a340c5c063aff7b8436d7
3
+ metadata.gz: b7c9f0953f60f411b88e66c914509308274d46c44a5fa42e1531740fc94c0be5
4
+ data.tar.gz: 1420e37a8f982fded587e1960309871054fc7e4a6ae4e237d5783025983a4c31
5
5
  SHA512:
6
- metadata.gz: c64a7e5a8c3252ceebe112312fa9dfa346c7c337c2ed528f72ab7d140d540333e99c580143bad2044a7fe57697360cf7be6cd36672e97224fa48f21a6d758b6d
7
- data.tar.gz: 7fdf180d08eb01a57acbf61f3f2a70754a433eee0fad1c31663f0b9bffa571ef4c45ada64669475ef6391b636437e3ae590e1bc27c785756278e1524f524cbfc
6
+ metadata.gz: 95efbe6ce15fd93acf8e4953ffbc058e681dda33f0a129a3b0a33c1c9000faf25a4bb789de45cd89603cfa2e5702b15c51db6468bbf616754199cf54e55cf750
7
+ data.tar.gz: dabea2ed5fddeda77f46fd7cee2a4f1b5f79d8dc042eba02dc64fda6ef304f828cce81d63c42a2592cd059511d080a6dd77db4ceb5de8dc17740e6d58fea04fb
data/.circleci/config.yml CHANGED
@@ -15,13 +15,37 @@ build_steps: &build_steps
15
15
  name: Run tests
16
16
  command: rake
17
17
 
18
+ ruby-2-4: &ruby-2-4
19
+ docker:
20
+ - image: circleci/ruby:2.4
21
+
18
22
  ruby-2-5: &ruby-2-5
19
23
  docker:
20
- - image: circleci/ruby:2.5
24
+ - image: cimg/ruby:2.5
21
25
 
22
26
  ruby-2-6: &ruby-2-6
23
27
  docker:
24
- - image: circleci/ruby:2.6
28
+ - image: cimg/ruby:2.6
29
+
30
+ ruby-2-7: &ruby-2-7
31
+ docker:
32
+ - image: cimg/ruby:2.7
33
+
34
+ ruby-3-0: &ruby-3-0
35
+ docker:
36
+ - image: cimg/ruby:3.0
37
+
38
+ ruby-3-1: &ruby-3-1
39
+ docker:
40
+ - image: cimg/ruby:3.1
41
+
42
+ rails-4-2: &rails-4-2
43
+ environment:
44
+ RAILS_VERSION: "~> 4.2.0"
45
+
46
+ rails-5-0: &rails-5-0
47
+ environment:
48
+ RAILS_VERSION: "~> 5.0.0"
25
49
 
26
50
  rails-5-1: &rails-5-1
27
51
  environment:
@@ -33,13 +57,42 @@ rails-5-2: &rails-5-2
33
57
 
34
58
  rails-6-0: &rails-6-0
35
59
  environment:
36
- RAILS_VERSION: "6.0.0.rc1"
60
+ RAILS_VERSION: "~> 6.0.0"
61
+
62
+ rails-6-1: &rails-6-1
63
+ environment:
64
+ RAILS_VERSION: "~> 6.1.0"
65
+
66
+ rails-7-0: &rails-7-0
67
+ environment:
68
+ RAILS_VERSION: "~> 7.0.0"
37
69
 
38
70
  rails-edge: &rails-edge
39
71
  environment:
40
- RAILS_BRANCH: "master"
72
+ RAILS_BRANCH: "main"
41
73
 
42
74
  jobs:
75
+ "ruby-2-4-rails-4-2":
76
+ <<: *ruby-2-4
77
+ <<: *rails-4-2
78
+ <<: *build_steps
79
+ "ruby-2-4-rails-5-0":
80
+ <<: *ruby-2-4
81
+ <<: *rails-5-0
82
+ <<: *build_steps
83
+ "ruby-2-4-rails-5-1":
84
+ <<: *ruby-2-4
85
+ <<: *rails-5-1
86
+ <<: *build_steps
87
+ "ruby-2-4-rails-5-2":
88
+ <<: *ruby-2-4
89
+ <<: *rails-5-2
90
+ <<: *build_steps
91
+
92
+ "ruby-2-5-rails-5-0":
93
+ <<: *ruby-2-5
94
+ <<: *rails-5-0
95
+ <<: *build_steps
43
96
  "ruby-2-5-rails-5-1":
44
97
  <<: *ruby-2-5
45
98
  <<: *rails-5-1
@@ -52,10 +105,19 @@ jobs:
52
105
  <<: *ruby-2-5
53
106
  <<: *rails-6-0
54
107
  <<: *build_steps
108
+ "ruby-2-5-rails-6-1":
109
+ <<: *ruby-2-5
110
+ <<: *rails-6-1
111
+ <<: *build_steps
55
112
  "ruby-2-5-rails-edge":
56
113
  <<: *ruby-2-5
57
114
  <<: *rails-edge
58
115
  <<: *build_steps
116
+
117
+ "ruby-2-6-rails-5-0":
118
+ <<: *ruby-2-6
119
+ <<: *rails-5-0
120
+ <<: *build_steps
59
121
  "ruby-2-6-rails-5-1":
60
122
  <<: *ruby-2-6
61
123
  <<: *rails-5-1
@@ -68,20 +130,112 @@ jobs:
68
130
  <<: *ruby-2-6
69
131
  <<: *rails-6-0
70
132
  <<: *build_steps
133
+ "ruby-2-6-rails-6-1":
134
+ <<: *ruby-2-6
135
+ <<: *rails-6-1
136
+ <<: *build_steps
71
137
  "ruby-2-6-rails-edge":
72
138
  <<: *ruby-2-6
73
139
  <<: *rails-edge
74
140
  <<: *build_steps
75
141
 
142
+ "ruby-2-7-rails-5-0":
143
+ <<: *ruby-2-7
144
+ <<: *rails-5-0
145
+ <<: *build_steps
146
+ "ruby-2-7-rails-5-1":
147
+ <<: *ruby-2-7
148
+ <<: *rails-5-1
149
+ <<: *build_steps
150
+ "ruby-2-7-rails-5-2":
151
+ <<: *ruby-2-7
152
+ <<: *rails-5-2
153
+ <<: *build_steps
154
+ "ruby-2-7-rails-6-0":
155
+ <<: *ruby-2-7
156
+ <<: *rails-6-0
157
+ <<: *build_steps
158
+ "ruby-2-7-rails-6-1":
159
+ <<: *ruby-2-7
160
+ <<: *rails-6-1
161
+ <<: *build_steps
162
+ "ruby-2-7-rails-7-0":
163
+ <<: *ruby-2-7
164
+ <<: *rails-7-0
165
+ <<: *build_steps
166
+ "ruby-2-7-rails-edge":
167
+ <<: *ruby-2-7
168
+ <<: *rails-edge
169
+ <<: *build_steps
170
+
171
+ "ruby-3-0-rails-6-0":
172
+ <<: *ruby-3-0
173
+ <<: *rails-6-0
174
+ <<: *build_steps
175
+ "ruby-3-0-rails-6-1":
176
+ <<: *ruby-3-0
177
+ <<: *rails-6-1
178
+ <<: *build_steps
179
+ "ruby-3-0-rails-7-0":
180
+ <<: *ruby-3-0
181
+ <<: *rails-7-0
182
+ <<: *build_steps
183
+ "ruby-3-0-rails-edge":
184
+ <<: *ruby-3-0
185
+ <<: *rails-edge
186
+ <<: *build_steps
187
+
188
+ "ruby-3-1-rails-6-0":
189
+ <<: *ruby-3-1
190
+ <<: *rails-6-0
191
+ <<: *build_steps
192
+ "ruby-3-1-rails-6-1":
193
+ <<: *ruby-3-1
194
+ <<: *rails-6-1
195
+ <<: *build_steps
196
+ "ruby-3-1-rails-7-0":
197
+ <<: *ruby-3-1
198
+ <<: *rails-7-0
199
+ <<: *build_steps
200
+ "ruby-3-1-rails-edge":
201
+ <<: *ruby-3-1
202
+ <<: *rails-edge
203
+ <<: *build_steps
204
+
76
205
  workflows:
77
206
  version: 2
78
207
  build:
79
208
  jobs:
209
+ - "ruby-2-4-rails-4-2"
210
+ - "ruby-2-4-rails-5-1"
211
+ - "ruby-2-4-rails-5-2"
212
+
213
+ - "ruby-2-5-rails-5-0"
80
214
  - "ruby-2-5-rails-5-1"
81
215
  - "ruby-2-5-rails-5-2"
82
216
  - "ruby-2-5-rails-6-0"
83
- - "ruby-2-5-rails-edge"
217
+ - "ruby-2-5-rails-6-1"
218
+
219
+ - "ruby-2-6-rails-5-0"
84
220
  - "ruby-2-6-rails-5-1"
85
221
  - "ruby-2-6-rails-5-2"
86
222
  - "ruby-2-6-rails-6-0"
87
- - "ruby-2-6-rails-edge"
223
+ - "ruby-2-6-rails-6-1"
224
+
225
+ - "ruby-2-7-rails-5-0"
226
+ - "ruby-2-7-rails-5-1"
227
+ - "ruby-2-7-rails-5-2"
228
+ - "ruby-2-7-rails-6-0"
229
+ - "ruby-2-7-rails-6-1"
230
+ - "ruby-2-7-rails-7-0"
231
+ - "ruby-2-7-rails-edge"
232
+
233
+ - "ruby-3-0-rails-6-0"
234
+ - "ruby-3-0-rails-6-1"
235
+ - "ruby-3-0-rails-7-0"
236
+ - "ruby-3-0-rails-edge"
237
+
238
+ - "ruby-3-1-rails-6-0"
239
+ - "ruby-3-1-rails-6-1"
240
+ - "ruby-3-1-rails-7-0"
241
+ - "ruby-3-1-rails-edge"
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # OmniAuth - Rails CSRF Protection
2
2
 
3
- This gem provides a mitigation against CVE-2015-9284 (Cross-Site Request
4
- Forgery on the request phrase when using OmniAuth gem with a Ruby on Rails
5
- application) by implementing a CSRF token verifier that directly utilize
3
+ This gem provides a mitigation against [CVE-2015-9284] (Cross-Site Request
4
+ Forgery on the request phase when using OmniAuth gem with a Ruby on Rails
5
+ application) by implementing a CSRF token verifier that directly uses
6
6
  `ActionController::RequestForgeryProtection` code from Rails.
7
7
 
8
+ [![CircleCI](https://circleci.com/gh/cookpad/omniauth-rails_csrf_protection/tree/main.svg?style=svg)](https://circleci.com/gh/cookpad/omniauth-rails_csrf_protection/tree/main)
9
+
10
+ [CVE-2015-9284]: https://nvd.nist.gov/vuln/detail/CVE-2015-9284
11
+
8
12
  ## Usage
9
13
 
10
14
  Add this line to your application's Gemfile:
@@ -16,7 +20,7 @@ gem "omniauth-rails_csrf_protection"
16
20
  Then run `bundle install` to install this gem.
17
21
 
18
22
  You will then need to verify that all links in your application that would
19
- initiate OAuth request phrase are being converted to a HTTP POST form that
23
+ initiate OAuth request phase are being converted to a HTTP POST form that
20
24
  contains `authenticity_token` value. This might simply be done by changing all
21
25
  `link_to` to `button_to`, or use `link_to ..., method: :post`.
22
26
 
@@ -24,10 +28,10 @@ contains `authenticity_token` value. This might simply be done by changing all
24
28
 
25
29
  This gem does a few things to your application:
26
30
 
27
- * Disable access to the OAuth request phrase using HTTP GET method.
28
- * Insert a Rails CSRF token verifier at before request phrase.
31
+ * Disable access to the OAuth request phase using HTTP GET method.
32
+ * Insert a Rails CSRF token verifier at the before request phase.
29
33
 
30
- These actions mitigate you from the attack vector described in CVE-2015-9284.
34
+ These actions mitigate you from the attack vector described in [CVE-2015-9284].
31
35
 
32
36
  ## Contributing
33
37
 
@@ -45,4 +49,4 @@ The gem is available as open source under the terms of the
45
49
 
46
50
  Everyone interacting in the this project’s codebases, issue trackers, chat
47
51
  rooms and mailing lists is expected to follow the
48
- [code of conduct](https://github.com/cookpad/omniauth-rails_csrf_protection/blob/master/CODE_OF_CONDUCT.md).
52
+ [code of conduct](https://github.com/cookpad/omniauth-rails_csrf_protection/blob/main/CODE_OF_CONDUCT.md).
@@ -1,11 +1,11 @@
1
+ require "omniauth"
1
2
  require "omniauth/rails_csrf_protection/token_verifier"
2
3
 
3
4
  module OmniAuth
4
5
  module RailsCsrfProtection
5
6
  class Railtie < Rails::Railtie
6
7
  initializer "omniauth-rails_csrf_protection.initialize" do
7
- OmniAuth.config.allowed_request_methods = [:post]
8
- OmniAuth.config.before_request_phase = TokenVerifier.new
8
+ OmniAuth.config.request_validation_phase = TokenVerifier.new
9
9
  end
10
10
  end
11
11
  end
@@ -28,7 +28,7 @@ module OmniAuth
28
28
  end
29
29
 
30
30
  def call(env)
31
- @request = ActionDispatch::Request.new(env)
31
+ @request = ActionDispatch::Request.new(env.dup)
32
32
 
33
33
  unless verified_request?
34
34
  raise ActionController::InvalidAuthenticityToken
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module RailsCsrfProtection
3
- VERSION = "0.1.0".freeze
3
+ VERSION = "1.0.1".freeze
4
4
  end
5
5
  end
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "actionpack", ">= 5.1.0"
31
- spec.add_dependency "omniauth", ">= 1.3.1"
30
+ spec.add_dependency "actionpack", ">= 4.2"
31
+ spec.add_dependency "omniauth", "~> 2.0"
32
32
 
33
33
  spec.add_development_dependency "bundler"
34
34
  spec.add_development_dependency "minitest"
@@ -11,14 +11,16 @@ class ApplicationTest < Minitest::Test
11
11
 
12
12
  def test_request_phrase_without_token_via_post
13
13
  post "/auth/developer"
14
+ follow_redirect!
14
15
 
15
- assert last_response.unprocessable?
16
+ assert last_response.not_found?
16
17
  end
17
18
 
18
19
  def test_request_phrase_with_bad_token_via_post
19
20
  post "/auth/developer", authenticity_token: "BAD_TOKEN"
21
+ follow_redirect!
20
22
 
21
- assert last_response.unprocessable?
23
+ assert last_response.not_found?
22
24
  end
23
25
 
24
26
  def test_request_phrase_with_correct_token_via_post
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-rails_csrf_protection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cookpad Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-30 00:00:00.000000000 Z
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.0
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.1.0
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.3.1
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.3.1
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +124,7 @@ homepage: https://github.com/cookpad/omniauth-rails_csrf_protection
124
124
  licenses:
125
125
  - MIT
126
126
  metadata: {}
127
- post_install_message:
127
+ post_install_message:
128
128
  rdoc_options: []
129
129
  require_paths:
130
130
  - lib
@@ -139,8 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 3.0.3
143
- signing_key:
142
+ rubygems_version: 3.2.32
143
+ signing_key:
144
144
  specification_version: 4
145
145
  summary: Provides CSRF protection on OmniAuth request endpoint on Rails application.
146
146
  test_files: