Class: Rack::Protection::RemoteReferrer

Inherits:
Base
  • Object
show all
Defined in:
lib/rack/protection/remote_referrer.rb

Overview

Prevented attack

CSRF

Supported browsers

all

More infos

en.wikipedia.org/wiki/Cross-site_request_forgery

Does not accept unsafe HTTP requests if the Referer [sic] header is set to a different host.

Combine with NoReferrer to also block remote requests from non-HTTP pages (FTP/HTTPS/…).

Constant Summary

Constants inherited from Base

Base::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Base

#app, #options

Instance Method Summary collapse

Methods inherited from Base

#call, #default_options, default_options, default_reaction, #deny, #drop_session, #encrypt, #initialize, #random_string, #react, #referrer, #safe?, #session, #session?, #warn

Constructor Details

This class inherits a constructor from Rack::Protection::Base

Instance Method Details

#accepts?(env) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rack/protection/remote_referrer.rb', line 18

def accepts?(env)
  safe?(env) or referrer(env) == Request.new(env).host
end