Class: Rack::Fernet
- Inherits:
-
Object
- Object
- Rack::Fernet
- Defined in:
- lib/rack/fernet.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, secret, content_type = "application/json") ⇒ Fernet
constructor
A new instance of Fernet.
Constructor Details
#initialize(app, secret, content_type = "application/json") ⇒ Fernet
Returns a new instance of Fernet.
23 24 25 26 27 |
# File 'lib/rack/fernet.rb', line 23 def initialize(app, secret, content_type="application/json") @app = app @secret = secret @content_type = content_type end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rack/fernet.rb', line 29 def call(env) if env["CONTENT_TYPE"] != 'application/octect-stream' && !env["rack.input"].size.zero? verifier = ::Fernet.verifier(@secret, env["rack.input"].read) if verifier.valid? env['CONTENT_TYPE'] = @content_type env["rack.input"] = StringIO.new(verifier.data || verifier.) @app.call(env) else bad_request end else @app.call(env) end end |