Class: Himari::Middlewares::AuthenticationRule

Inherits:
Object
  • Object
show all
Defined in:
lib/himari/middlewares/authentication_rule.rb

Constant Summary collapse

RACK_KEY =
'himari.authn_rule'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, kwargs = {}, &block) ⇒ AuthenticationRule

Returns a new instance of AuthenticationRule.



9
10
11
12
13
# File 'lib/himari/middlewares/authentication_rule.rb', line 9

def initialize(app, kwargs = {}, &block)
  @app = app
  @rule = Himari::Rule.new(block: block, **kwargs)
  @provider = Himari::ItemProviders::Static.new([@rule])
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



15
16
17
# File 'lib/himari/middlewares/authentication_rule.rb', line 15

def app
  @app
end

#clientObject (readonly)

Returns the value of attribute client.



15
16
17
# File 'lib/himari/middlewares/authentication_rule.rb', line 15

def client
  @client
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/himari/middlewares/authentication_rule.rb', line 17

def call(env)
  env[RACK_KEY] ||= []
  env[RACK_KEY] += [@provider]
  @app.call(env)
end