1
0
Fork 0
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:
Konstantin Haase 2013-10-21 11:38:36 +02:00
parent a428f6e138
commit 5d4f1d8ba3
2 changed files with 3 additions and 4 deletions

View file

@ -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)

View file

@ -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