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/authorization.rb,
lib/declarative_authorization/in_controller.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: Attribute, AttributeAuthorizationError, AttributeWithPermission, AuthorizationError, AuthorizationRule, AuthorizationUsageError, ControllerPermission, Engine, GuestUser, NilAttributeValueError, NotAuthorized, ObligationScope

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.activate_authorization_rules_browser?Boolean

:nodoc:

Returns:

  • (Boolean)


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

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

.current_userObject

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



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

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

.current_user=(user) ⇒ Object

Controller-independent method for setting the current user.



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

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

.dot_pathObject



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

def self.dot_path
  @@dot_path
end

.dot_path=(path) ⇒ Object



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

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

.ignore_access_control(state = nil) ⇒ Object

For use in test cases only



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

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