z_acl (zotonic_core v1.0.0-rc.10)

Access control for Zotonic. Interfaces to modules implementing the ACL events.

Link to this section Summary

Functions

Call a function as the anonymous user.
Return a term that can be used as the ACL part of cache key.
Check if the current user is an admin or a sudo action
Check if an admin is logged on and the read only flag is not set. Exception for sudo, where updates are always allowed.
Check if an action is allowed for the current actor.
Check if an action on a property of a resource is allowed for the current actor.
Check if the current access permissions are set to read-only. This is an authorization option for the current z.auth cookie or bearer token.
Check if the current context acl is set using a sudo.
Log off, reset the acl field of the context
Log the user with the id on, fill the acl field of the context
Log the user with the id on, fill acl and set all user preferences (like timezone and language)
Refresh the authentication of the current user
Check if the resource is deletable by the current user
Check if the resource is editable by the current user
Check if the resource is connected to another resource by the current user
Check if a property of the resource is visible for the current user
Check if the resource is visible for the current user
Set the current context to read only. Models can use this state to prevent updates to data.
Call a function with admin privileges.
Return the id of the current user.
Return the list of user groups the current context is member of.

Link to this section Types

-type acl() :: [operationrequest()].
-type action() :: use | admin | view | insert | update | delete | link | atom().
Link to this type

maybe_boolean/0

-type maybe_boolean() :: undefined | boolean().
-type object() :: m_rsc:resource() | #acl_rsc{} | #acl_edge{} | #acl_media{} | any().
Link to this type

operationrequest/0

-type operationrequest() :: {action(), object()}.

Link to this section Functions

Link to this function

anondo(Context)

-spec anondo(z:context()) -> z:context().
Link to this function

anondo(Fun, Context)

-spec anondo(Fun, z:context()) -> any()
          when Fun :: {module(), atom()} | mfa() | fun((z:context()) -> any()).
Call a function as the anonymous user.
Link to this function

cache_key(Context)

-spec cache_key(z:context()) -> {m_rsc:resource_id() | undefined, any()}.
Return a term that can be used as the ACL part of cache key.
Link to this function

is_admin(Context)

-spec is_admin(z:context()) -> boolean().
Check if the current user is an admin or a sudo action
Link to this function

is_admin_editable(Context)

-spec is_admin_editable(z:context()) -> boolean().
Check if an admin is logged on and the read only flag is not set. Exception for sudo, where updates are always allowed.
Link to this function

is_allowed(Action, Object, Context)

-spec is_allowed(action(), object(), z:context()) -> boolean().
Check if an action is allowed for the current actor.
Link to this function

is_allowed_prop(Action, Object, Property, Context)

-spec is_allowed_prop(action(), object(), atom() | binary(), z:context()) -> true | false | undefined.
Check if an action on a property of a resource is allowed for the current actor.
Link to this function

is_read_only(Context)

-spec is_read_only(z:context()) -> boolean().
Check if the current access permissions are set to read-only. This is an authorization option for the current z.auth cookie or bearer token.
Link to this function

is_sudo(Context)

-spec is_sudo(z:context()) -> boolean().
Check if the current context acl is set using a sudo.
Link to this function

logoff(Context)

-spec logoff(z:context()) -> z:context().
Log off, reset the acl field of the context
Link to this function

logon(Id, Context)

-spec logon(m_rsc:resource() | undefined, z:context()) -> z:context().
Log the user with the id on, fill the acl field of the context
Link to this function

logon(Id, Options, Context)

-spec logon(m_rsc:resource() | undefined, map(), z:context()) -> z:context().
Link to this function

logon_prefs(Id, Context)

-spec logon_prefs(m_rsc:resource_id(), z:context()) -> z:context().
Log the user with the id on, fill acl and set all user preferences (like timezone and language)
Link to this function

logon_prefs(Id, Options, Context)

-spec logon_prefs(m_rsc:resource_id(), map(), z:context()) -> z:context().
Link to this function

logon_refresh(Context)

-spec logon_refresh(z:context()) -> z:context().
Refresh the authentication of the current user
Link to this function

maybe_allowed(Action, Object, Context)

-spec maybe_allowed(action(), object(), z:context()) -> maybe_boolean().
Link to this function

rsc_deletable(Id, Context)

-spec rsc_deletable(m_rsc:resource(), z:context()) -> boolean().
Check if the resource is deletable by the current user
Link to this function

rsc_editable(Id, Context)

-spec rsc_editable(m_rsc:resource(), z:context()) -> boolean().
Check if the resource is editable by the current user
Link to this function

rsc_linkable(Id, Context)

-spec rsc_linkable(m_rsc:resource(), z:context()) -> boolean().
Check if the resource is connected to another resource by the current user
Link to this function

rsc_prop_visible(Id, Property, Context)

-spec rsc_prop_visible(m_rsc:resource(), atom() | binary(), z:context()) -> boolean().
Check if a property of the resource is visible for the current user
Link to this function

rsc_visible(Id, Context)

-spec rsc_visible(m_rsc:resource(), z:context()) -> boolean().
Check if the resource is visible for the current user
Link to this function

set_read_only(IsReadOnly, Context)

-spec set_read_only(boolean(), z:context()) -> z:context().
Set the current context to read only. Models can use this state to prevent updates to data.
-spec sudo(z:context()) -> z:context().
Link to this function

sudo(Fun, Context)

-spec sudo(Fun, z:context()) -> any()
        when Fun :: {module(), atom()} | mfa() | fun((z:context()) -> any()).
Call a function with admin privileges.
-spec user(z:context()) -> m_rsc:resource_id() | undefined.
Return the id of the current user.
Link to this function

user_groups(Context)

-spec user_groups(z:context()) -> [m_rsc:resource_id()].
Return the list of user groups the current context is member of.