class Rack::Protection::HttpOrigin
- does not match default or whitelisted URIs.
Does not accept unsafe HTTP requests when value of Origin HTTP request header
More infos - en.wikipedia.org/wiki/Cross-site_request_forgery<br>Supported browsers
- Google Chrome 2, Safari 4 and later
Prevented attack -
CSRF
#
- Google Chrome 2, Safari 4 and later
def accepts?(env)
def accepts?(env) return true if safe? env return true unless origin = env['HTTP_ORIGIN'] return true if base_url(env) == origin Array(options[:origin_whitelist]).include? origin end
def base_url(env)
def base_url(env) request = Rack::Request.new(env) port = ":#{request.port}" unless request.port == DEFAULT_PORTS[request.scheme] "#{request.scheme}://#{request.host}#{port}" end