Class: Tasker::Authorization::ResourceRegistry
- Inherits:
-
Object
- Object
- Tasker::Authorization::ResourceRegistry
- Includes:
- ResourceConstants
- Defined in:
- lib/tasker/authorization/resource_registry.rb
Overview
Resource registry defining available resources and their permitted actions for authorization purposes.
This registry serves as a central catalog of all resources that can be authorized within the Tasker system. Each resource defines a set of actions that can be performed on it.
Constant Summary collapse
- RESOURCES =
Registry of all available resources and their permitted actions
{ ResourceConstants::RESOURCES::TASK => { actions: [ ResourceConstants::ACTIONS::INDEX, ResourceConstants::ACTIONS::SHOW, ResourceConstants::ACTIONS::CREATE, ResourceConstants::ACTIONS::UPDATE, ResourceConstants::ACTIONS::DESTROY, ResourceConstants::ACTIONS::RETRY, ResourceConstants::ACTIONS::CANCEL ], description: 'Tasker workflow tasks' }, ResourceConstants::RESOURCES::WORKFLOW_STEP => { actions: [ ResourceConstants::ACTIONS::INDEX, ResourceConstants::ACTIONS::SHOW, ResourceConstants::ACTIONS::UPDATE, ResourceConstants::ACTIONS::DESTROY, ResourceConstants::ACTIONS::RETRY, ResourceConstants::ACTIONS::CANCEL ], description: 'Individual workflow steps' }, ResourceConstants::RESOURCES::HEALTH_STATUS => { actions: [ ResourceConstants::ACTIONS::INDEX ], description: 'Health status endpoint information' }, ResourceConstants::RESOURCES::HANDLER => { actions: [ ResourceConstants::ACTIONS::INDEX, ResourceConstants::ACTIONS::SHOW ], description: 'Handler discovery and metadata' }, ResourceConstants::RESOURCES::METRICS => { actions: [ ResourceConstants::ACTIONS::INDEX ], description: 'Prometheus metrics endpoint' }, ResourceConstants::RESOURCES::ANALYTICS => { actions: [ ResourceConstants::ACTIONS::INDEX ], description: 'Analytics and performance monitoring endpoints' } }.freeze
Class Method Summary collapse
-
.action_exists?(resource, action) ⇒ Boolean
Check if an action is valid for a given resource.
-
.actions_for_resource(resource) ⇒ Array<Symbol>
Get all actions for a specific resource.
-
.all_permissions ⇒ Array<String>
Get all available permissions in "resource:action" format.
-
.resource_description(resource) ⇒ String?
Get description for a resource.
-
.resource_exists?(resource) ⇒ Boolean
Check if a resource exists in the registry.
-
.resources ⇒ Hash
Get all registered resources.
Class Method Details
.action_exists?(resource, action) ⇒ Boolean
Check if an action is valid for a given resource
99 100 101 102 103 |
# File 'lib/tasker/authorization/resource_registry.rb', line 99 def action_exists?(resource, action) return false unless resource_exists?(resource) RESOURCES[resource][:actions].include?(action.to_sym) end |
.actions_for_resource(resource) ⇒ Array<Symbol>
Get all actions for a specific resource
118 119 120 121 122 |
# File 'lib/tasker/authorization/resource_registry.rb', line 118 def actions_for_resource(resource) return [] unless resource_exists?(resource) RESOURCES[resource][:actions] end |
.all_permissions ⇒ Array<String>
Get all available permissions in "resource:action" format
108 109 110 111 112 |
# File 'lib/tasker/authorization/resource_registry.rb', line 108 def RESOURCES.flat_map do |resource, config| config[:actions].map { |action| "#{resource}:#{action}" } end end |
.resource_description(resource) ⇒ String?
Get description for a resource
128 129 130 131 132 |
# File 'lib/tasker/authorization/resource_registry.rb', line 128 def resource_description(resource) return nil unless resource_exists?(resource) RESOURCES[resource][:description] end |
.resource_exists?(resource) ⇒ Boolean
Check if a resource exists in the registry
90 91 92 |
# File 'lib/tasker/authorization/resource_registry.rb', line 90 def resource_exists?(resource) RESOURCES.key?(resource) end |
.resources ⇒ Hash
Get all registered resources
82 83 84 |
# File 'lib/tasker/authorization/resource_registry.rb', line 82 def resources RESOURCES end |