rack-cors 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack-cors might be problematic. Click here for more details.
- data/VERSION +1 -1
- data/lib/rack/cors.rb +2 -2
- data/rack-cors.gemspec +20 -24
- data/test/cors_test.rb +7 -1
- data/test/test.ru +2 -1
- metadata +55 -57
- data/.gitignore +0 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/lib/rack/cors.rb
CHANGED
@@ -120,7 +120,7 @@ module Rack
|
|
120
120
|
def initialize(public_resource, path, opts={})
|
121
121
|
self.path = path
|
122
122
|
self.methods = ensure_enum(opts[:methods]) || [:get]
|
123
|
-
self.credentials = opts[:credentials]
|
123
|
+
self.credentials = opts[:credentials].nil? ? true : opts[:credentials]
|
124
124
|
self.max_age = opts[:max_age] || 1728000
|
125
125
|
self.pattern = compile(path)
|
126
126
|
@public_resource = public_resource
|
@@ -146,7 +146,7 @@ module Rack
|
|
146
146
|
|
147
147
|
def to_headers(env)
|
148
148
|
x_origin = env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']
|
149
|
-
h = { 'Access-Control-Allow-Origin' => public_resource? ? '*' : env['HTTP_ORIGIN'],
|
149
|
+
h = { 'Access-Control-Allow-Origin' => credentials ? env['HTTP_ORIGIN'] : public_resource? ? '*' : env['HTTP_ORIGIN'],
|
150
150
|
'Access-Control-Allow-Methods' => methods.collect{|m| m.to_s.upcase}.join(', '),
|
151
151
|
'Access-Control-Expose-Headers' => expose.nil? ? '' : expose.join(', '),
|
152
152
|
'Access-Control-Max-Age' => max_age.to_s }
|
data/rack-cors.gemspec
CHANGED
@@ -1,51 +1,47 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.2.
|
7
|
+
s.name = "rack-cors"
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Calvin Yu"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-04-26"
|
13
|
+
s.description = "Middleware that will make Rack-based apps CORS compatible. Read more here: http://blog.sourcebender.com/2010/06/09/introducin-rack-cors.html. Fork the project here: http://github.com/cyu/rack-cors"
|
14
|
+
s.email = "csyu77@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
"rack-cors.gemspec",
|
25
|
-
"test/cors_test.rb",
|
26
|
-
"test/dsl_test.rb",
|
27
|
-
"test/test.ru"
|
28
|
-
]
|
29
|
-
s.homepage = %q{http://github.com/cyu/rack-cors}
|
30
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
-
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.7}
|
33
|
-
s.summary = %q{Middleware for enabling Cross-Origin Resource Sharing in Rack apps}
|
34
|
-
s.test_files = [
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"lib/rack/cors.rb",
|
23
|
+
"rack-cors.gemspec",
|
35
24
|
"test/cors_test.rb",
|
36
|
-
|
25
|
+
"test/dsl_test.rb",
|
26
|
+
"test/test.ru"
|
37
27
|
]
|
28
|
+
s.homepage = "http://github.com/cyu/rack-cors"
|
29
|
+
s.require_paths = ["lib"]
|
30
|
+
s.rubygems_version = "1.8.23"
|
31
|
+
s.summary = "Middleware for enabling Cross-Origin Resource Sharing in Rack apps"
|
38
32
|
|
39
33
|
if s.respond_to? :specification_version then
|
40
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
34
|
s.specification_version = 3
|
42
35
|
|
43
36
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
37
|
+
s.add_runtime_dependency(%q<rack-cors>, [">= 0"])
|
44
38
|
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
45
39
|
else
|
40
|
+
s.add_dependency(%q<rack-cors>, [">= 0"])
|
46
41
|
s.add_dependency(%q<rack>, [">= 0"])
|
47
42
|
end
|
48
43
|
else
|
44
|
+
s.add_dependency(%q<rack-cors>, [">= 0"])
|
49
45
|
s.add_dependency(%q<rack>, [">= 0"])
|
50
46
|
end
|
51
47
|
end
|
data/test/cors_test.rb
CHANGED
@@ -87,6 +87,12 @@ class CorsTest < Test::Unit::TestCase
|
|
87
87
|
should '* origin should allow any origin' do
|
88
88
|
preflight_request('http://locohost:3000', '/public')
|
89
89
|
assert_cors_success
|
90
|
+
assert_equal 'http://locohost:3000', last_response.headers['Access-Control-Allow-Origin']
|
91
|
+
end
|
92
|
+
|
93
|
+
should '* origin should allow any origin, and set * if no credentials required' do
|
94
|
+
preflight_request('http://locohost:3000', '/public_without_credentials')
|
95
|
+
assert_cors_success
|
90
96
|
assert_equal '*', last_response.headers['Access-Control-Allow-Origin']
|
91
97
|
end
|
92
98
|
|
@@ -127,4 +133,4 @@ class CorsTest < Test::Unit::TestCase
|
|
127
133
|
def assert_cors_failure
|
128
134
|
assert_nil last_response.headers['Access-Control-Allow-Origin'], 'no expecting Access-Control-Allow-Origin header'
|
129
135
|
end
|
130
|
-
end
|
136
|
+
end
|
data/test/test.ru
CHANGED
@@ -19,9 +19,10 @@ use Rack::Cors do
|
|
19
19
|
allow do
|
20
20
|
origins '*'
|
21
21
|
resource '/public'
|
22
|
+
resource '/public_without_credentials', :credentials => false
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
map '/' do
|
26
27
|
run Proc.new { |env| [200, {'Content-Type' => 'text/html'}, ['success']] }
|
27
|
-
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,47 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-cors
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 4
|
10
|
-
version: 0.2.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.5
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Calvin Yu
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
date: 2012-04-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack-cors
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rack
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
25
33
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
33
38
|
type: :runtime
|
34
|
-
|
35
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! 'Middleware that will make Rack-based apps CORS compatible. Read more
|
47
|
+
here: http://blog.sourcebender.com/2010/06/09/introducin-rack-cors.html. Fork the
|
48
|
+
project here: http://github.com/cyu/rack-cors'
|
36
49
|
email: csyu77@gmail.com
|
37
50
|
executables: []
|
38
|
-
|
39
51
|
extensions: []
|
40
|
-
|
41
|
-
extra_rdoc_files:
|
52
|
+
extra_rdoc_files:
|
42
53
|
- README.rdoc
|
43
|
-
files:
|
44
|
-
- .gitignore
|
54
|
+
files:
|
45
55
|
- README.rdoc
|
46
56
|
- Rakefile
|
47
57
|
- VERSION
|
@@ -50,40 +60,28 @@ files:
|
|
50
60
|
- test/cors_test.rb
|
51
61
|
- test/dsl_test.rb
|
52
62
|
- test/test.ru
|
53
|
-
has_rdoc: true
|
54
63
|
homepage: http://github.com/cyu/rack-cors
|
55
64
|
licenses: []
|
56
|
-
|
57
65
|
post_install_message:
|
58
|
-
rdoc_options:
|
59
|
-
|
60
|
-
require_paths:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
61
68
|
- lib
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
70
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
|
69
|
-
- 0
|
70
|
-
version: "0"
|
71
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
76
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
version: "0"
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
80
81
|
requirements: []
|
81
|
-
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.23
|
84
84
|
signing_key:
|
85
85
|
specification_version: 3
|
86
86
|
summary: Middleware for enabling Cross-Origin Resource Sharing in Rack apps
|
87
|
-
test_files:
|
88
|
-
- test/cors_test.rb
|
89
|
-
- test/dsl_test.rb
|
87
|
+
test_files: []
|
data/.gitignore
DELETED