mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
let json_csrf always deny, fixes #50
This commit is contained in:
parent
a428f6e138
commit
5d4f1d8ba3
2 changed files with 3 additions and 4 deletions
|
@ -11,7 +11,7 @@ module Rack
|
|||
# Array prototype has been patched to track data. Checks the referrer
|
||||
# even on GET requests if the content type is JSON.
|
||||
class JsonCsrf < Base
|
||||
default_reaction :deny
|
||||
alias react deny
|
||||
|
||||
def call(env)
|
||||
request = Request.new(env)
|
||||
|
|
|
@ -44,7 +44,7 @@ describe Rack::Protection::JsonCsrf do
|
|||
end
|
||||
|
||||
describe 'with drop_session as default reaction' do
|
||||
it 'reset the session' do
|
||||
it 'still denies' do
|
||||
mock_app do
|
||||
use Rack::Protection, :reaction => :drop_session
|
||||
run proc { |e| [200, {'Content-Type' => 'application/json'}, []]}
|
||||
|
@ -52,8 +52,7 @@ describe Rack::Protection::JsonCsrf do
|
|||
|
||||
session = {:foo => :bar}
|
||||
get('/', {}, 'HTTP_REFERER' => 'http://evil.com', 'rack.session' => session)
|
||||
last_response.should be_ok
|
||||
session.should be_empty
|
||||
last_response.should_not be_ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue