mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Show warnings for a JsonCsrf
attack.
Since the `JsonCsrf` middleware overrides the `call` method, the default warning is never displayed. I couldn't figure out why sinatra was returning a 403 for CORS and JSONP requests, tracked it down to this.
This commit is contained in:
parent
7b74143147
commit
d528b5aa6c
1 changed files with 4 additions and 1 deletions
|
@ -16,7 +16,10 @@ module Rack
|
|||
def call(env)
|
||||
status, headers, body = app.call(env)
|
||||
if headers['Content-Type'].to_s.split(';', 2).first =~ /^\s*application\/json\s*$/
|
||||
result = react(env) if referrer(env) != Request.new(env).host
|
||||
if referrer(env) != Request.new(env).host
|
||||
result = react(env)
|
||||
warn env, "attack prevented by #{self.class}"
|
||||
end
|
||||
end
|
||||
result or [status, headers, body]
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue