Module: Arrow::AccessControls

Includes:
AppletAuthentication
Defined in:
lib/arrow/appletmixins.rb

Overview

Add access-control to all actions and then allow them to be removed on a per-action basis via a directive.

Defined Under Namespace

Modules: ClassMethods

Constant Summary

UNAUTHENTICATED_ACTIONS =

Actions which don’t go through access control

[
  :deny_access, :login, :logout
].freeze

Class Method Summary

Instance Method Summary

Methods included from AppletAuthentication

#deny_access_action, #get_authenticated_user, #login_action, #logout_action, #user_is_authorized, #with_authentication, #with_authorization

Class Method Details

+ (Object) included(mod)

Inclusion callback



180
181
182
183
184
185
# File 'lib/arrow/appletmixins.rb', line 180

def self::included( mod )
  Arrow::Logger[ self ].debug "Adding declarative method to %p" % [ mod ]
  mod.instance_variable_set( :@unauthenticated_actions, UNAUTHENTICATED_ACTIONS.dup )
  mod.extend( ClassMethods )
  super
end

Instance Method Details

- (Object) delegate(txn, chain, *args)

Delegate to applets further on in the chain only if the user is authorized.



205
206
207
208
209
210
211
# File 'lib/arrow/appletmixins.rb', line 205

def delegate( txn, chain, *args )
  self.log.debug "Delegating to chain: %p" % [ chain ]

  with_authorization( txn, chain ) do
    yield( chain )
  end
end

- (Object) find_action_method(txn, action = nil, *args)

Overridden to map the action to the authorization action’s method if action isn’t one of the ones that’s defined as unauthenticated.



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/arrow/appletmixins.rb', line 190

def find_action_method( txn, action=nil, *args )
  if self.class.unauthenticated_actions.include?( action )
    self.log.debug "Supering to unauthenticated action %p" % [ action ]
    super
  else
    self.log.debug "Action %p wasn't marked as unauthenticated; checking authorization." %
      [ action ]
    with_authorization( txn, action, *args ) do
      super
    end
  end
end