Class: Grape::Middleware::Auth::Base
- Inherits:
-
Object
- Object
- Grape::Middleware::Auth::Base
- Includes:
- Helpers
- Defined in:
- lib/grape/middleware/auth/base.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#env ⇒ Object
Returns the value of attribute env.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, *options) ⇒ Base
constructor
A new instance of Base.
Methods included from Helpers
Constructor Details
#initialize(app, *options) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/grape/middleware/auth/base.rb', line 11 def initialize(app, *) @app = app @options = .shift end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
9 10 11 |
# File 'lib/grape/middleware/auth/base.rb', line 9 def app @app end |
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/grape/middleware/auth/base.rb', line 9 def env @env end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/grape/middleware/auth/base.rb', line 9 def @options end |
Instance Method Details
#_call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/grape/middleware/auth/base.rb', line 20 def _call(env) self.env = env if .key?(:type) auth_proc = [:proc] auth_proc_context = context strategy_info = Grape::Middleware::Auth::Strategies[[:type]] throw(:error, status: 401, message: 'API Authorization Failed.') if strategy_info.blank? strategy = strategy_info.create(@app, ) do |*args| auth_proc_context.instance_exec(*args, &auth_proc) end strategy.call(env) else app.call(env) end end |
#call(env) ⇒ Object
16 17 18 |
# File 'lib/grape/middleware/auth/base.rb', line 16 def call(env) dup._call(env) end |