rack-cors 1.0.2 → 2.0.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 +5 -5
- data/{CHANGELOG → CHANGELOG.md} +47 -0
- data/README.md +66 -43
- data/lib/rack/cors/resource.rb +142 -0
- data/lib/rack/cors/resources/cors_misconfiguration_error.rb +14 -0
- data/lib/rack/cors/resources.rb +62 -0
- data/lib/rack/cors/result.rb +63 -0
- data/lib/rack/cors/version.rb +3 -1
- data/lib/rack/cors.rb +110 -345
- metadata +80 -56
- data/.travis.yml +0 -6
- data/Gemfile +0 -6
- data/Rakefile +0 -21
- data/rack-cors.gemspec +0 -26
- data/test/cors/expect.js +0 -1286
- data/test/cors/mocha.css +0 -250
- data/test/cors/mocha.js +0 -5373
- data/test/cors/runner.html +0 -20
- data/test/cors/test.cors.coffee +0 -42
- data/test/cors/test.cors.js +0 -67
- data/test/unit/cors_test.rb +0 -482
- data/test/unit/dsl_test.rb +0 -69
- data/test/unit/insecure.ru +0 -8
- data/test/unit/non_http.ru +0 -8
- data/test/unit/test.ru +0 -60
data/test/unit/non_http.ru
DELETED
data/test/unit/test.ru
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'rack/cors'
|
2
|
-
|
3
|
-
#use Rack::Cors, :debug => true, :logger => ::Logger.new(STDOUT) do
|
4
|
-
use Rack::Lint
|
5
|
-
use Rack::Cors do
|
6
|
-
allow do
|
7
|
-
origins 'localhost:3000',
|
8
|
-
'127.0.0.1:3000',
|
9
|
-
/http:\/\/192\.168\.0\.\d{1,3}(:\d+)?/,
|
10
|
-
'file://',
|
11
|
-
/http:\/\/(.*?)\.example\.com/
|
12
|
-
|
13
|
-
resource '/get-only', :methods => :get
|
14
|
-
resource '/', :headers => :any, :methods => :any
|
15
|
-
resource '/options', :methods => :options
|
16
|
-
resource '/single_header', :headers => 'x-domain-token'
|
17
|
-
resource '/two_headers', :headers => %w{x-domain-token x-requested-with}
|
18
|
-
resource '/expose_single_header', :expose => 'expose-test'
|
19
|
-
resource '/expose_multiple_headers', :expose => %w{expose-test-1 expose-test-2}
|
20
|
-
resource '/conditional', :methods => :get, :if => proc { |env| !!env['HTTP_X_OK'] }
|
21
|
-
resource '/vary_test', :methods => :get, :vary => %w{ Origin Host }
|
22
|
-
# resource '/file/at/*',
|
23
|
-
# :methods => [:get, :post, :put, :delete],
|
24
|
-
# :headers => :any,
|
25
|
-
# :max_age => 0
|
26
|
-
end
|
27
|
-
|
28
|
-
allow do
|
29
|
-
origins do |source,env|
|
30
|
-
source.end_with?("10.10.10.10:3000")
|
31
|
-
end
|
32
|
-
resource '/proc-origin'
|
33
|
-
end
|
34
|
-
|
35
|
-
allow do
|
36
|
-
origins -> (source, env) { source.end_with?("10.10.10.10:3000") }
|
37
|
-
resource '/lambda-origin'
|
38
|
-
end
|
39
|
-
|
40
|
-
allow do
|
41
|
-
origins '*'
|
42
|
-
resource '/public'
|
43
|
-
resource '/public_without_credentials', :credentials => false
|
44
|
-
end
|
45
|
-
|
46
|
-
allow do
|
47
|
-
origins 'mucho-grande.com'
|
48
|
-
resource '/multi-allow-config', :max_age => 600
|
49
|
-
end
|
50
|
-
|
51
|
-
allow do
|
52
|
-
origins '*'
|
53
|
-
resource '/multi-allow-config', :max_age => 300, :credentials => false
|
54
|
-
end
|
55
|
-
|
56
|
-
allow do
|
57
|
-
origins ''
|
58
|
-
resource '/blank-origin'
|
59
|
-
end
|
60
|
-
end
|