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, #env, #options

Instance Method Summary collapse

Methods inherited from Base

#after, #before, #call, #content_type, #content_type_for, #content_types, #context, #mime_types, #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
# File 'lib/grape/middleware/auth/base.rb', line 7

def initialize(app, **options)
  super
  @auth_strategy = Grape::Middleware::Auth::Strategies[options[:type]].tap do |auth_strategy|
    raise Grape::Exceptions::UnknownAuthStrategy.new(strategy: options[:type]) unless auth_strategy
  end
end

Instance Method Details

#call!(env) ⇒ Object



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

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