Class: Textus::Dispatch::Middleware::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/textus/dispatch/middleware/auth.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, middleware_name

Instance Method Details

#call(container:, command:, call:, next_handler:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/textus/dispatch/middleware/auth.rb', line 7

def call(container:, command:, call:, next_handler:)
  verb = VerbRegistry.contract_to_verb!(command.class).to_sym
  key = key_for(command)

  rule_preds = key ? rule_declared_predicates(verb, container.manifest, key) : []

  Manifest::Policy::Predicates.evaluate(
    manifest: container.manifest, schemas: container.schemas,
    action: verb, actor: call.role, key: key,
    rule_predicates: rule_preds
  )

  next_handler.call(command, call)
end