Module: Authorization

Defined in:
lib/declarative_authorization/helper.rb,
lib/declarative_authorization/reader.rb,
lib/declarative_authorization/in_model.rb,
lib/declarative_authorization/maintenance.rb,
lib/declarative_authorization/railsengine.rb,
lib/declarative_authorization/in_controller.rb,
lib/declarative_authorization/authorization.rb,
lib/declarative_authorization/obligation_scope.rb,
lib/declarative_authorization/development_support/analyzer.rb,
lib/declarative_authorization/development_support/change_analyzer.rb,
lib/declarative_authorization/development_support/change_supporter.rb,
lib/declarative_authorization/development_support/development_support.rb

Defined Under Namespace

Modules: AuthorizationHelper, AuthorizationInController, AuthorizationInModel, DevelopmentSupport, Maintenance, Reader, TestHelper Classes: AnonymousUser, Attribute, AttributeAuthorizationError, AttributeWithPermission, AuthorizationError, AuthorizationRule, AuthorizationRuleSet, AuthorizationUsageError, ControllerPermission, Engine, NilAttributeValueError, NotAuthorized, ObligationScope, RailsEngine

Constant Summary

AUTH_DSL_FILES =
[Pathname.new(Rails.root || '').join("config", "authorization_rules.rb").to_s]
@@dot_path =
"dot"
@@default_role =
:guest

Class Method Summary (collapse)

Class Method Details

+ (Boolean) activate_authorization_rules_browser?

:nodoc:

Returns:

  • (Boolean)


42
43
44
# File 'lib/declarative_authorization/authorization.rb', line 42

def self.activate_authorization_rules_browser? # :nodoc:
  ::Rails.env.development?
end

+ (Object) current_user

Controller-independent method for retrieving the current user. Needed for model security where the current controller is not available.



27
28
29
# File 'lib/declarative_authorization/authorization.rb', line 27

def self.current_user
  Thread.current["current_user"] || AnonymousUser.new
end

+ (Object) current_user=(user)

Controller-independent method for setting the current user.



32
33
34
# File 'lib/declarative_authorization/authorization.rb', line 32

def self.current_user=(user)
  Thread.current["current_user"] = user
end

+ (Object) default_role



56
57
58
# File 'lib/declarative_authorization/authorization.rb', line 56

def self.default_role
  @@default_role
end

+ (Object) default_role=(role)



60
61
62
# File 'lib/declarative_authorization/authorization.rb', line 60

def self.default_role= (role)
  @@default_role = role.to_sym
end

+ (Object) dot_path



47
48
49
# File 'lib/declarative_authorization/authorization.rb', line 47

def self.dot_path
  @@dot_path
end

+ (Object) dot_path=(path)



51
52
53
# File 'lib/declarative_authorization/authorization.rb', line 51

def self.dot_path= (path)
  @@dot_path = path
end

+ (Object) ignore_access_control(state = nil)

For use in test cases only



37
38
39
40
# File 'lib/declarative_authorization/authorization.rb', line 37

def self.ignore_access_control (state = nil) # :nodoc:
  Thread.current["ignore_access_control"] = state unless state.nil?
  Thread.current["ignore_access_control"] || false
end

+ (Boolean) is_a_association_proxy?(object)

Returns:

  • (Boolean)


64
65
66
67
68
69
70
# File 'lib/declarative_authorization/authorization.rb', line 64

def self.is_a_association_proxy? (object)
  if Rails.version < "3.2"
    object.respond_to?(:proxy_reflection)
  else
    object.respond_to?(:proxy_association)
  end
end