Class: UnifiedCsrfPrevention::Middleware
- Inherits:
-
Object
- Object
- UnifiedCsrfPrevention::Middleware
- Defined in:
- lib/unified_csrf_prevention/middleware.rb
Overview
Rack middleware to set the token and checksum cookies See github.com/xing/cross-application-csrf-prevention#token-generation
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 |
# File 'lib/unified_csrf_prevention/middleware.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/unified_csrf_prevention/middleware.rb', line 13 def call(env) status, headers, body = @app.call(env) if env.key?(Core::TOKEN_RACK_ENV_VAR) token = env[Core::TOKEN_RACK_ENV_VAR] (headers, token) Rails.logger.info("Set CSRF token: #{token}") end [status, headers, body] end |