Authorizations Systems and Be9's Acl 9
Authorizations Systems and Be9's Acl 9
●
Access Control
Authorization occurs from a block in the controller
feature allow and deny statements.
access_control do
allow :manager
deny :peon
end
Access Control(cont)
Allow :manager, :to => [:index, :create]
deny :manager, :except => [:index, :create]
Access Control(cont)
● Can also check role relations to variables.
● Set the variable in a before_filter
● Allow :manager, :of => @widget, :to => :edit
● :of is aliased lots for more gooder english. You can
use: :of, :at, :on, :by, :for, :in
Access Control(cont)
● You can also add :if or :unless to the end of
access control statements.
● Allow :manager, :to => :update, :if => :gives_raise
def gives_raise
params[:salary] > @salary.value
end
● Methods must return true or false.
Access Denied
● Catch Acl9::AccessDenied errors in the
controller with rescue_from.
● Often worth catching these conditionally in the
controller for specific access problems and then
raising to a generic block in the
application_controller.