Class: Legion::Extensions::Identity::Entra::Helpers::ScopeRegistry
- Inherits:
-
Object
- Object
- Legion::Extensions::Identity::Entra::Helpers::ScopeRegistry
- Defined in:
- lib/legion/extensions/identity/entra/helpers/scope_registry.rb
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #denied ⇒ Object
- #granted ⇒ Object
-
#initialize(pattern:) ⇒ ScopeRegistry
constructor
A new instance of ScopeRegistry.
- #permitted?(scope) ⇒ Boolean
- #permitted_all?(*scopes) ⇒ Boolean
- #permitted_any?(*scopes) ⇒ Boolean
- #record_granted(scopes) ⇒ Object
- #record_requested(scopes) ⇒ Object
- #requested ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(pattern:) ⇒ ScopeRegistry
Returns a new instance of ScopeRegistry.
13 14 15 16 17 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 13 def initialize(pattern:) @pattern = pattern.to_sym @requested = Concurrent::AtomicReference.new([]) @granted = Concurrent::AtomicReference.new([]) end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
11 12 13 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 11 def pattern @pattern end |
Instance Method Details
#denied ⇒ Object
49 50 51 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 49 def denied @requested.get - @granted.get end |
#granted ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 23 def granted @granted.get.dup end |
#permitted?(scope) ⇒ Boolean
35 36 37 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 35 def permitted?(scope) @granted.get.include?(scope.to_s) end |
#permitted_all?(*scopes) ⇒ Boolean
39 40 41 42 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 39 def permitted_all?(*scopes) granted_set = @granted.get scopes.flatten.all? { |s| granted_set.include?(s.to_s) } end |
#permitted_any?(*scopes) ⇒ Boolean
44 45 46 47 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 44 def permitted_any?(*scopes) granted_set = @granted.get scopes.flatten.any? { |s| granted_set.include?(s.to_s) } end |
#record_granted(scopes) ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 31 def record_granted(scopes) @granted.set(normalize(scopes).uniq.freeze) end |
#record_requested(scopes) ⇒ Object
27 28 29 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 27 def record_requested(scopes) @requested.set(normalize(scopes).uniq.freeze) end |
#requested ⇒ Object
19 20 21 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 19 def requested @requested.get.dup end |
#reset! ⇒ Object
53 54 55 56 |
# File 'lib/legion/extensions/identity/entra/helpers/scope_registry.rb', line 53 def reset! @requested.set([]) @granted.set([]) end |