rack-cors 2.0.1 → 3.0.0

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: f47b5b2ba34721795ddb1c65e70e989134655e7f47116dd977edee702a79f41f
4
- data.tar.gz: 7c03dc701b00b7418ab4d733872fccc3522392f0f85014b8ca25045767d866a9
3
+ metadata.gz: 6ec00fa74e332230fa5a169a7de9b04f09cdc062653f1cc09ca05806fb25152f
4
+ data.tar.gz: a628117ab53ce1ec3ade0bef0f073d5edc4ce7a908122a741534f64ff4e90a3e
5
5
  SHA512:
6
- metadata.gz: d5a94b8f282fd5367e125f4b49e18ce5fb1c07581d89b2d50dc8cf4eb70e8404d97c78a6ccaf90f1e41f0f220bb09ff9dd07a4677559935cc35256674e6c512d
7
- data.tar.gz: bee187e2dc53281d8b454df32b6a8fd50e05b66de4f25649d74f176abf29d52eb4cee5a2b2e602e087c5f5805b6dd55ab86a9e0692d3d82c5538e0c30e3c020b
6
+ metadata.gz: 7f3ffafae36ad8e08a5d5f4347628ef6efaf9dcd669d008e1ea4022998e6d36bef652c9b99fc5c89d36af10cfbc508269154df722ca7629831642206ee3b078c
7
+ data.tar.gz: f849c6fa986e0e601dc18532591fcde9c03557ee2fb1ecbf2e19f518e7ec0824a8d665c4c8764872fccbd674d754c7453fc333eb72c93d27c586b4ebf5c1b913
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 3.0.0 - 2025-05-16
5
+ ### Changed
6
+ - Update Rack dependency to >= 3.0.14
7
+ - Remove support for Ruby 2.3
8
+ - Add logger as explicit dependency
9
+
10
+ ## 2.0.2 - 2024-03-04
11
+ ### Changed
12
+ - Fix file permission issues with 2.0.1 release
13
+ - Security: Fixes CVE-2024-27456, GHSA-785g-282q-pwvx
14
+
4
15
  ## 2.0.1 - 2023-02-17
5
16
  ### Changed
6
17
  - Use Rack::Utils::HeaderHash when Rack 2.x is detected
data/README.md CHANGED
@@ -33,18 +33,12 @@ Rails.application.config.middleware.insert_before 0, Rack::Cors do
33
33
  end
34
34
  ```
35
35
 
36
- NOTE: If you create application with `--api` option, configuration automatically generate in `config/initializers/cors.rb`.
36
+ NOTE: If you create application with `--api` option, configuration is automatically generated in `config/initializers/cors.rb`.
37
37
 
38
38
  We use `insert_before` to make sure `Rack::Cors` runs at the beginning of the stack to make sure it isn't interfered with by other middleware (see `Rack::Cache` note in **Common Gotchas** section). Basic setup examples for Rails 5 & Rails 6 can be found in the examples/ directory.
39
39
 
40
40
  See The [Rails Guide to Rack](http://guides.rubyonrails.org/rails_on_rack.html) for more details on rack middlewares or watch the [railscast](http://railscasts.com/episodes/151-rack-middleware).
41
41
 
42
- *Note about Rails 6*: Rails 6 has support for blocking requests from unknown hosts, so origin domains will need to be added there as well.
43
-
44
- ```ruby
45
- Rails.application.config.hosts << "product.com"
46
- ```
47
-
48
42
  Read more about it here in the [Rails Guides](https://guides.rubyonrails.org/configuring.html#configuring-middleware)
49
43
 
50
44
  ### Rack Configuration
@@ -113,7 +107,9 @@ A Resource path can be specified as exact string match (`/path/to/file.txt`) or
113
107
 
114
108
  ### Origin Matching
115
109
 
116
- When specifying an origin, make sure that it does not have a trailing slash.
110
+ * When specifying an origin, make sure that it does not have a trailing slash.
111
+
112
+ * When specifying an HTTP origin that uses the scheme's default port (e.g. `http://example.test:80`), some clients may not strip the port which could result in unexpected blocked requests (additional context [here](https://github.com/request/request/pull/2904)).
117
113
 
118
114
  ### Testing Postman and/or cURL
119
115
 
@@ -135,13 +131,13 @@ Here are some scenarios where incorrect positioning have created issues:
135
131
  You can run the following command to see what the middleware stack looks like:
136
132
 
137
133
  ```bash
138
- bundle exec rake middleware
134
+ bundle exec rails middleware
139
135
  ```
140
136
 
141
137
  Note that the middleware stack is different in production. For example, the `ActionDispatch::Static` middleware will not be part of the stack if `config.serve_static_assets = false`. You can run this to see what your middleware stack looks like in production:
142
138
 
143
139
  ```bash
144
- RAILS_ENV=production bundle exec rake middleware
140
+ RAILS_ENV=production bundle exec rails middleware
145
141
  ```
146
142
 
147
143
  ### Serving static files
@@ -158,3 +154,7 @@ has a custom protocol (`chrome-extension://`, `ionic://`, etc.) simply exclude t
158
154
  For example, instead of specifying `chrome-extension://aomjjhallfgjeglblehebfpbcfeobpga` specify `aomjjhallfgjeglblehebfpbcfeobpga` in `origins`.
159
155
 
160
156
  As of 2.0.0 (currently in RC1), you can specify origins with a custom protocol.
157
+
158
+ ### Rails 6 Host Matching
159
+
160
+ Rails 6 will block requests from unauthorized hosts, and this issue can be confused as a CORS related error. So in development, if you're making requests using something other than localhost or 127.0.0.1, make sure the server host has been authorized. [More info here](https://guides.rubyonrails.org/configuring.html#actiondispatch-hostauthorization)
@@ -106,7 +106,7 @@ module Rack
106
106
 
107
107
  def compile(path)
108
108
  if path.respond_to? :to_str
109
- special_chars = %w[. + ( )]
109
+ special_chars = %w[. + ( ) $]
110
110
  pattern =
111
111
  path.to_str.gsub(%r{((:\w+)|/\*|[\*#{special_chars.join}])}) do |match|
112
112
  case match
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Cors
5
- VERSION = '2.0.1'
5
+ VERSION = '3.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calvin Yu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-17 00:00:00.000000000 Z
11
+ date: 2025-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rack
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: 2.0.0
33
+ version: 3.0.14
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 2.0.0
40
+ version: 3.0.14
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -48,30 +62,30 @@ dependencies:
48
62
  name: minitest
49
63
  requirement: !ruby/object:Gem::Requirement
50
64
  requirements:
51
- - - "~>"
65
+ - - ">="
52
66
  - !ruby/object:Gem::Version
53
- version: 5.11.0
67
+ version: '0'
54
68
  type: :development
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
- - - "~>"
72
+ - - ">="
59
73
  - !ruby/object:Gem::Version
60
- version: 5.11.0
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: mocha
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
- - - "~>"
79
+ - - ">="
66
80
  - !ruby/object:Gem::Version
67
- version: 1.6.0
81
+ version: '0'
68
82
  type: :development
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - "~>"
86
+ - - ">="
73
87
  - !ruby/object:Gem::Version
74
- version: 1.6.0
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: pry
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -136,37 +150,22 @@ executables: []
136
150
  extensions: []
137
151
  extra_rdoc_files: []
138
152
  files:
139
- - ".github/workflows/ci.yaml"
140
- - ".rubocop.yml"
141
153
  - CHANGELOG.md
142
- - Gemfile
143
154
  - LICENSE.txt
144
155
  - README.md
145
- - Rakefile
146
156
  - lib/rack/cors.rb
147
157
  - lib/rack/cors/resource.rb
148
158
  - lib/rack/cors/resources.rb
149
159
  - lib/rack/cors/resources/cors_misconfiguration_error.rb
150
160
  - lib/rack/cors/result.rb
151
161
  - lib/rack/cors/version.rb
152
- - rack-cors.gemspec
153
- - test/.rubocop.yml
154
- - test/cors/expect.js
155
- - test/cors/mocha.css
156
- - test/cors/mocha.js
157
- - test/cors/runner.html
158
- - test/cors/test.cors.coffee
159
- - test/cors/test.cors.js
160
- - test/unit/cors_test.rb
161
- - test/unit/dsl_test.rb
162
- - test/unit/insecure.ru
163
- - test/unit/non_http.ru
164
- - test/unit/test.ru
165
162
  homepage: https://github.com/cyu/rack-cors
166
163
  licenses:
167
164
  - MIT
168
- metadata: {}
169
- post_install_message:
165
+ metadata:
166
+ changelog_uri: https://github.com/cyu/rack-cors/blob/master/CHANGELOG.md
167
+ funding_uri: https://github.com/sponsors/cyu
168
+ post_install_message:
170
169
  rdoc_options: []
171
170
  require_paths:
172
171
  - lib
@@ -181,20 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
180
  - !ruby/object:Gem::Version
182
181
  version: '0'
183
182
  requirements: []
184
- rubygems_version: 3.3.26
185
- signing_key:
183
+ rubygems_version: 3.4.19
184
+ signing_key:
186
185
  specification_version: 4
187
186
  summary: Middleware for enabling Cross-Origin Resource Sharing in Rack apps
188
- test_files:
189
- - test/.rubocop.yml
190
- - test/cors/expect.js
191
- - test/cors/mocha.css
192
- - test/cors/mocha.js
193
- - test/cors/runner.html
194
- - test/cors/test.cors.coffee
195
- - test/cors/test.cors.js
196
- - test/unit/cors_test.rb
197
- - test/unit/dsl_test.rb
198
- - test/unit/insecure.ru
199
- - test/unit/non_http.ru
200
- - test/unit/test.ru
187
+ test_files: []
@@ -1,39 +0,0 @@
1
- name: ci
2
-
3
- on:
4
- - push
5
- - pull_request
6
-
7
- jobs:
8
- test:
9
- strategy:
10
- fail-fast: false
11
- matrix:
12
- ruby:
13
- - "2.3"
14
- - "2.4"
15
- - "2.5"
16
- - "2.6"
17
- - "2.7"
18
- - "3.0"
19
- - "3.1"
20
- - "3.2"
21
- - truffleruby-head
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v3
25
- - uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby }}
28
- bundler-cache: true
29
- - run: bundle exec rake test
30
-
31
- rubocop:
32
- runs-on: ubuntu-latest
33
- steps:
34
- - uses: actions/checkout@v3
35
- - uses: ruby/setup-ruby@v1
36
- with:
37
- ruby-version: 3.2.1
38
- bundler-cache: true
39
- - run: bundle exec rubocop
data/.rubocop.yml DELETED
@@ -1,31 +0,0 @@
1
- ---
2
- AllCops:
3
- Exclude:
4
- - "examples/**/*"
5
- - "vendor/**/*"
6
-
7
- # Disables
8
- Layout/LineLength:
9
- Enabled: false
10
- Style/Documentation:
11
- Enabled: false
12
- Metrics/ClassLength:
13
- Enabled: false
14
- Metrics/MethodLength:
15
- Enabled: false
16
- Metrics/BlockLength:
17
- Enabled: false
18
- Style/HashEachMethods:
19
- Enabled: false
20
- Style/HashTransformKeys:
21
- Enabled: false
22
- Style/HashTransformValues:
23
- Enabled: false
24
- Style/DoubleNegation:
25
- Enabled: false
26
- Metrics/CyclomaticComplexity:
27
- Enabled: false
28
- Metrics/PerceivedComplexity:
29
- Enabled: false
30
- Metrics/AbcSize:
31
- Enabled: false
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in rack-cors.gemspec
6
- gemspec
7
-
8
- gem 'pry-byebug', '~> 3.6.0'
data/Rakefile DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
-
5
- require 'rake/testtask'
6
- Rake::TestTask.new(:test) do |test|
7
- test.libs << 'lib' << 'test'
8
- test.pattern = 'test/**/*_test.rb'
9
- test.verbose = true
10
- end
11
-
12
- task default: :test
13
-
14
- require 'rdoc/task'
15
- Rake::RDocTask.new do |rdoc|
16
- version = File.exist?('VERSION') ? File.read('VERSION') : ''
17
-
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = "rack-cors #{version}"
20
- rdoc.rdoc_files.include('README*')
21
- rdoc.rdoc_files.include('lib/**/*.rb')
22
- end
data/rack-cors.gemspec DELETED
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'rack/cors/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'rack-cors'
9
- spec.version = Rack::Cors::VERSION
10
- spec.authors = ['Calvin Yu']
11
- spec.email = ['me@sourcebender.com']
12
- spec.description = 'Middleware that will make Rack-based apps CORS compatible. Fork the project here: https://github.com/cyu/rack-cors'
13
- spec.summary = 'Middleware for enabling Cross-Origin Resource Sharing in Rack apps'
14
- spec.homepage = 'https://github.com/cyu/rack-cors'
15
- spec.license = 'MIT'
16
-
17
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).reject { |f| (f == '.gitignore') || f =~ /^examples/ }
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ['lib']
21
-
22
- spec.add_dependency 'rack', '>= 2.0.0'
23
- spec.add_development_dependency 'bundler', '>= 1.16.0', '< 3'
24
- spec.add_development_dependency 'minitest', '~> 5.11.0'
25
- spec.add_development_dependency 'mocha', '~> 1.6.0'
26
- spec.add_development_dependency 'pry', '~> 0.12'
27
- spec.add_development_dependency 'rack-test', '>= 1.1.0'
28
- spec.add_development_dependency 'rake', '~> 12.3.0'
29
- spec.add_development_dependency 'rubocop', '~> 0.80.1'
30
- end
data/test/.rubocop.yml DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- inherit_from: ../.rubocop.yml
3
-
4
- # Disables
5
- Style/ClassAndModuleChildren:
6
- Enabled: false
7
- Security/Eval:
8
- Enabled: false