Class: Textus::Gate::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/gate/auth.rb

Defined Under Namespace

Classes: AuthContext

Constant Summary collapse

FLOOR =
{
  put: %w[lane_writable_by],
  key_delete: %w[lane_writable_by],
  key_mv: %w[lane_writable_by],
  accept: %w[author_held],
  reject: %w[author_held],
  propose: %w[lane_writable_by],
  key_mv_prefix: %w[lane_writable_by],
  key_delete_prefix: %w[lane_writable_by],
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ Auth

Returns a new instance of Auth.



24
25
26
27
# File 'lib/textus/gate/auth.rb', line 24

def initialize(container)
  @manifest = container.manifest
  @schemas = container.schemas
end

Class Method Details

.command_to_verbObject



54
55
56
# File 'lib/textus/gate/auth.rb', line 54

def self.command_to_verb
  @command_to_verb ||= Textus::Gate::VERB_COMMAND.invert.freeze
end

Instance Method Details

#check!(cmd) ⇒ Object

Command-based check (new Gate path).



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/textus/gate/auth.rb', line 30

def check!(cmd)
  key = extract_key(cmd)
  return unless key

  evaluate_predicates(
    action: command_to_action(cmd),
    actor: cmd.role.to_s,
    key: key,
    envelope: nil,
    extra: {},
  )
end

#check_action!(action:, actor:, key:, envelope: nil, extra: {}) ⇒ Object

Backward-compatible check for inline action auth (accept, put, etc.).



44
45
46
47
48
49
50
51
52
# File 'lib/textus/gate/auth.rb', line 44

def check_action!(action:, actor:, key:, envelope: nil, extra: {})
  evaluate_predicates(
    action: action.to_sym,
    actor: actor,
    key: key,
    envelope: envelope,
    extra: extra,
  )
end