Module: Legion::Extensions::Identity::Entra::Helpers::ScopeGate::ClassMethods

Defined in:
lib/legion/extensions/identity/entra/helpers/scope_gate.rb

Instance Method Summary collapse

Instance Method Details

#available_methodsObject



30
31
32
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 30

def available_methods
  required_scopes.select { |_, req| scope_satisfied?(req) }.keys
end

#method_permitted?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 38

def method_permitted?(method_name)
  req = required_scopes[method_name.to_sym]
  return true unless req

  scope_satisfied?(req)
end

#required_scopesObject



22
23
24
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 22

def required_scopes
  @required_scopes ||= {}
end

#requires_scope(method_name, *scopes, all: true) ⇒ Object



26
27
28
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 26

def requires_scope(method_name, *scopes, all: true)
  required_scopes[method_name.to_sym] = { scopes: scopes.flatten, all: all }
end

#scope_patternObject



14
15
16
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 14

def scope_pattern
  @scope_pattern || :delegated
end

#scope_requirementsObject



45
46
47
48
49
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 45

def scope_requirements
  required_scopes.transform_values do |req|
    { scopes: req[:scopes], permitted: scope_satisfied?(req) }
  end
end

#unavailable_methodsObject



34
35
36
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 34

def unavailable_methods
  required_scopes.reject { |_, req| scope_satisfied?(req) }.keys
end

#uses_pattern(pattern) ⇒ Object



18
19
20
# File 'lib/legion/extensions/identity/entra/helpers/scope_gate.rb', line 18

def uses_pattern(pattern)
  @scope_pattern = pattern.to_sym
end