Module: Scimitar::Rbac

Defined in:
lib/scimitar/rbac.rb,
lib/scimitar/rbac/engine.rb,
lib/scimitar/rbac/version.rb,
lib/scimitar/rbac/route_helper.rb

Defined Under Namespace

Modules: RouteHelper Classes: Engine

Constant Summary collapse

URN_PREFIX =

URN prefix for RBAC extension schemas

"urn:ietf:params:scim:schemas:extension:rbac:2.0"
VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.load!Object

Eagerly load all RBAC components. Called after Rails and scimitar are fully initialized (via Engine initializer or manually).



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/scimitar/rbac.rb', line 15

def self.load!
  return if @loaded

  # Complex-type schema classes must be loaded before the complex-type
  # classes that reference them (via set_schema), which in turn must be
  # loaded before the resource schema classes that embed them as attributes.
  require_relative "rbac/schema/hierarchy_member"
  require_relative "rbac/schema/role_assignment"
  require_relative "rbac/schema/entitlement_assignment"
  require_relative "rbac/schema/application_reference"

  # Complex types (must be loaded before resource schemas that reference them)
  require_relative "rbac/complex_types/hierarchy_member"
  require_relative "rbac/complex_types/role_assignment"
  require_relative "rbac/complex_types/entitlement_assignment"
  require_relative "rbac/complex_types/application_reference"

  # Resource schemas
  require_relative "rbac/schema/role"
  require_relative "rbac/schema/entitlement"
  require_relative "rbac/schema/application"

  # Resources
  require_relative "rbac/resources/role"
  require_relative "rbac/resources/entitlement"
  require_relative "rbac/resources/application"

  @loaded = true
end

.register_resources!Object

Register all RBAC resources with the Scimitar engine. Called automatically by the Rails engine, or can be called manually.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/scimitar/rbac.rb', line 47

def self.register_resources!
  load!

  # Guard by endpoint string rather than class identity so the check
  # is stable across dev-mode code reloads (gem classes don't reload,
  # but endpoints are plain strings that always compare equal).
  registered_endpoints = Scimitar::Engine.custom_resources.map(&:endpoint)

  [
    Scimitar::Resources::Rbac::Role,
    Scimitar::Resources::Rbac::Entitlement,
    Scimitar::Resources::Rbac::Application
  ].each do |resource|
    unless registered_endpoints.include?(resource.endpoint)
      Scimitar::Engine.add_custom_resource(resource)
    end
  end
end

.reset!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reset load state — useful for testing



68
69
70
# File 'lib/scimitar/rbac.rb', line 68

def self.reset!
  @loaded = false
end