Class: Rack::CSRF

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/csrf.rb,
lib/rack/csrf/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ CSRF

Returns a new instance of CSRF.



9
10
11
12
13
# File 'lib/rack/csrf.rb', line 9

def initialize(app, opts = {})
  @app = app
  @exclude = opts[:exclude]
  set_trusted_origins(opts)
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
# File 'lib/rack/csrf.rb', line 15

def call(env)
  return @app.call(env) if safe_request?(env)

  [ 403, {}, ["Forbidden\n"]]
end