ACL notifications¶
acl_context_authenticated¶
Set the context to a typical authenticated uses. Used by m_acl.erl
- Type:
- first
- Return:
- authenticated
#context{}orundefined
#acl_context_authenticated{} properties:
none
acl_is_allowed¶
Check if a user is authorized to perform an operation on a an object
(some resource or module). Observe this notification to do complex or more
fine-grained authorization checks than you can do through the ACL rules admin
interface. Defaults to false.
- Type:
- first
- Return:
trueto allow the operation,falseto deny it orundefinedto let the next observer decide#acl_is_allowed{}properties:- action:
view|update|delete|insert|use|atom - object:
term
- action:
Example¶
Deny anyone from viewing unpublished resource except those who have update rights on the resource (usually the creator and the administrator):
observe_acl_is_allowed(#acl_is_allowed{action = view, object = Id}, Context) ->
case m_rsc:p_no_acl(Id, is_published_date, Context) of
undefined ->
%% Let next observer decide
undefined;
true ->
%% Resource is published: let next observer decide
undefined;
false ->
%% Resource is unpublished
case z_acl:is_allowed(update, Id, Context) of
true ->
%% User has update rights, so let next observer decide
undefined;
false ->
%% Deny viewing rights on unpublished resource
false
end
end;
observe_acl_is_allowed(#acl_is_allowed{}, _Context) ->
%% Fall through
undefined.
In this observer, we return undefined in those cases where we do not
want to deny access. We don’t grant the access right away but give the next
observer the change to decide whether viewing is allowed (for instance, based on
the resource’s category and content group and the user’s group).
acl_is_allowed_prop¶
Check if a user is authorizded to perform an action on a property.
Defaults to true.
- Type:
- first
- Return:
trueto grant access,falseto deny it,undefinedto let the next observer decide#acl_is_allowed_prop{}properties:- action:
view|update|delete|insert|atom - object:
term - prop:
atom
- action:
acl_is_owner¶
Check if a user is the owner of a resource.
id is the resource id.
- Type:
- first
- Return:
true,falseorundefinedto let the next observer decide#acl_is_owner{}properties:- id:
integer - creator_id:
integer - user_id:
integer
- id:
acl_logoff¶
Clear the associated access policy for the context.
- Type:
- first
- Return:
- updated
#context{}orundefined
#acl_logoff{} properties:
none