Module: Authz

Defined in:
lib/authz.rb,
lib/authz/cache.rb,
lib/authz/engine.rb,
lib/authz/version.rb,
app/models/authz/role.rb,
lib/authz/models/rolable.rb,
lib/authz/scopables/base.rb,
app/models/authz/role_grant.rb,
app/models/authz/scoping_rule.rb,
lib/authz/helpers/view_helpers.rb,
app/models/authz/business_process.rb,
app/models/authz/controller_action.rb,
app/models/authz/application_record.rb,
app/helpers/authz/application_helper.rb,
app/controllers/authz/home_controller.rb,
lib/authz/controllers/scoping_manager.rb,
app/controllers/authz/roles_controller.rb,
app/controllers/authz/rolables_controller.rb,
app/models/authz/role_has_business_process.rb,
lib/authz/controllers/authorization_manager.rb,
app/controllers/authz/application_controller.rb,
app/controllers/authz/scoping_rules_controller.rb,
lib/generators/authz/install/install_generator.rb,
app/controllers/authz/business_processes_controller.rb,
app/controllers/authz/controller_actions_controller.rb,
app/controllers/authz/validations/role_names_controller.rb,
app/models/authz/business_process_has_controller_action.rb,
app/controllers/authz/bulk/controller_actions_controller.rb,
app/controllers/authz/stale_controller_actions_controller.rb,
app/controllers/authz/validations/action_names_controller.rb,
app/controllers/authz/pending_controller_actions_controller.rb,
app/controllers/authz/validations/controller_names_controller.rb,
app/controllers/authz/validations/business_process_names_controller.rb

Overview

Stores the configuration parameters of the library

Defined Under Namespace

Modules: ApplicationHelper, Cache, Controllers, Generators, Helpers, Models, Scopables Classes: ApplicationController, ApplicationRecord, BusinessProcess, BusinessProcessHasControllerAction, BusinessProcessesController, ControllerAction, ControllerActionsController, Engine, HomeController, MultileRolablesNotPermitted, PendingControllerActionsController, RolablesController, Role, RoleGrant, RoleHasBusinessProcess, RolesController, ScopingRule, ScopingRulesController, StaleControllerActionsController

Constant Summary collapse

VERSION =
'0.0.5'
@@rolables =
[]
@@force_authentication_method =

The method controllers use to force authentication

:authenticate_user!
@@current_user_method =

The method used to access the instance of a current user

:current_user
@@cross_request_caching =

Configuration to enable cross request caching

false
@@cache =

The attribute that points to the cache module

Authz::Cache

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure {|_self| ... } ⇒ Object

Allows the configuration of the gem using block syntax

Examples:

Authz.configure do |config|
  config.current_user_method = :current_user
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Authz)

    the object that the method was called on



63
64
65
# File 'lib/authz.rb', line 63

def self.configure
  yield self
end

.register_rolable(rolable) ⇒ 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.

Adds a rolable to the configuration

Parameters:

  • rolable (Rolable)

    rolable class



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/authz.rb', line 29

def self.register_rolable(rolable)
  unless @@rolables.map{|r| r.model_name.name}.include?(rolable.model_name.name)
    @@rolables << rolable
  end

  # TODO: When support for multiple rolables is implemented, lift this exception
  if @@rolables.size > 1
    raise MultileRolablesNotPermitted,
          "Only the Authorization of one model (like a User) is currently supported"
  end
end

Instance Method Details

#rolablesRolable

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.

Returns classes of al rolables.

Returns:

  • (Rolable)

    classes of al rolables



23
# File 'lib/authz.rb', line 23

mattr_reader :rolables