Class: Grape::Middleware::Auth::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/grape/middleware/auth/base.rb

Instance Attribute Summary

Attributes inherited from Base

#app, #config, #env, #options

Instance Method Summary collapse

Methods inherited from Base

#after, #before, #call, #context, #query_params, #rack_request, #response

Methods included from DSL::Headers

#header

Constructor Details

#initialize(app, **options) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/grape/middleware/auth/base.rb', line 7

def initialize(app, **options)
  super
  return unless options.key?(:type)

  @auth_strategy = Grape::Middleware::Auth::Strategies[options[:type]]
  raise Grape::Exceptions::UnknownAuthStrategy.new(strategy: options[:type]) unless @auth_strategy
end

Instance Method Details

#call!(env) ⇒ Object



15
16
17
18
19
20
# File 'lib/grape/middleware/auth/base.rb', line 15

def call!(env)
  @env = env
  @auth_strategy.create(app, options) do |*args|
    context.instance_exec(*args, &options[:proc])
  end.call(env)
end