Class: Wix::Apps::SignedInstanceMiddleware
- Inherits:
-
Struct
- Object
- Struct
- Wix::Apps::SignedInstanceMiddleware
- Defined in:
- lib/wix-apps/signed_instance_middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ SignedInstanceMiddleware
constructor
A new instance of SignedInstanceMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ SignedInstanceMiddleware
Returns a new instance of SignedInstanceMiddleware.
4 5 6 7 |
# File 'lib/wix-apps/signed_instance_middleware.rb', line 4 def initialize(app, ={}) @app = app end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
3 4 5 |
# File 'lib/wix-apps/signed_instance_middleware.rb', line 3 def app @app end |
#options ⇒ Object
Returns the value of attribute options
3 4 5 |
# File 'lib/wix-apps/signed_instance_middleware.rb', line 3 def @options end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wix-apps/signed_instance_middleware.rb', line 9 def call(env) @env = env if secured_path? @request = Rack::Request.new(env) if have_instance? begin @instance = Wix::Apps::SignedInstance.new(@request.params['instance'], secret: [:secret_key]) rescue Wix::Apps::SignedInstanceParseError => e return [403, {}, ['Invalid wix instance']] end if @instance.valid? parse_instance! @app.call(env) else [403, {}, ['Invalid wix instance']] end else [401, {}, ['Unauthorized']] end else @app.call(env) end end |