mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Replace origin_permitted with permitted_origins
This commit is contained in:
parent
166da3084d
commit
472b61045d
2 changed files with 4 additions and 4 deletions
|
|
@ -11,9 +11,9 @@ module Rack
|
||||||
# Does not accept unsafe HTTP requests when value of Origin HTTP request header
|
# Does not accept unsafe HTTP requests when value of Origin HTTP request header
|
||||||
# does not match default or permitted URIs.
|
# does not match default or permitted URIs.
|
||||||
#
|
#
|
||||||
# If you want to permit a specific domain, you can pass in as the `:origin_permitted` option:
|
# If you want to permit a specific domain, you can pass in as the `:permitted_origins` option:
|
||||||
#
|
#
|
||||||
# use Rack::Protection, origin_permitted: ["http://localhost:3000", "http://127.0.01:3000"]
|
# use Rack::Protection, permitted_origins: ["http://localhost:3000", "http://127.0.01:3000"]
|
||||||
#
|
#
|
||||||
# The `:allow_if` option can also be set to a proc to use custom allow/deny logic.
|
# The `:allow_if` option can also be set to a proc to use custom allow/deny logic.
|
||||||
class HttpOrigin < Base
|
class HttpOrigin < Base
|
||||||
|
|
@ -38,7 +38,7 @@ module Rack
|
||||||
"use origin_whitelist instead.\n"
|
"use origin_whitelist instead.\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
permitted_origins = options[:origin_permitted] || options[:origin_whitelist]
|
permitted_origins = options[:permitted_origins] || options[:origin_whitelist]
|
||||||
Array(permitted_origins).include? origin
|
Array(permitted_origins).include? origin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ describe Rack::Protection::HttpOrigin do
|
||||||
|
|
||||||
it "accepts #{method} requests with whitelisted Origin" do
|
it "accepts #{method} requests with whitelisted Origin" do
|
||||||
mock_app do
|
mock_app do
|
||||||
use Rack::Protection::HttpOrigin, :origin_permitted => ['http://www.friend.com']
|
use Rack::Protection::HttpOrigin, :permitted_origins => ['http://www.friend.com']
|
||||||
run DummyApp
|
run DummyApp
|
||||||
end
|
end
|
||||||
expect(send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://www.friend.com')).to be_ok
|
expect(send(method.downcase, '/', {}, 'HTTP_ORIGIN' => 'http://www.friend.com')).to be_ok
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue