View Source Bonfire.Boundaries.Controlleds (Bonfire v0.9.10-classic-beta.169)
An object is linked to one or more Acl
s by the Controlled
multimixin, which pairs an object ID with an ACL ID.
Because it is a multimixin, a given object can have multiple ACLs applied. In the case of overlap, permissions are combined with false
being prioritised.
The Controlled
multimixin link an object to one or more ACLs. This allows for applying multiple boundaries to the same object. In case of overlapping permissions, the system combines them following the logic described in Bonfire.Boundaries
.
The corresponding Ecto schema is Bonfire.Data.AccessControl.Controlled
which is defined in a seperate repo.
Summary
Functions
Adds the given ACL to an object.
Returns a changeset for a Controlled
with the given attributes.
Creates a Controlled
record with the given attributes.
Gets a preset ACL applied to an object, if any.
Grants a role to a subject for an object.
Lists ACLs applied to an object. Only call this as an admin or curator of the object.
Lists grants of a given verb on specified object(s).
Lists ALL boundaries (ACLs and grants) applied to an object. Only call this as an admin or curator of the object.
Lists ACLs applied to the given objects by the subject (current_user).
Lists presets ACLs applied to the given objects.
Lists subjects who have been granted a given verb on specified object(s).
Removes the given ACLs from an object.
Functions
Adds the given ACL to an object.
Examples
iex> add_acls(object, :acl)
{:ok, %Controlled{}}
Returns a changeset for a Controlled
with the given attributes.
Examples
iex> changeset(%Controlled{}, %{field: value})
%Ecto.Changeset{}
Creates a Controlled
record with the given attributes.
Examples
iex> create(%{field: value})
{:ok, %Controlled{}}
Gets a preset ACL applied to an object, if any.
Examples
iex> get_preset_on_object(object)
%ACL{}
Grants a role to a subject for an object.
Examples
iex> grant_role(subject_id, object, :editor)
{:ok, %Grant{}}
Lists ACLs applied to an object. Only call this as an admin or curator of the object.
Examples
iex> list_acls_on_object(object)
[%Acl{}]
Lists grants of a given verb on specified object(s).
Examples
iex> list_grants_by_verbs(objects, :read)
iex> list_grants_by_verbs(objects, :edit, false)
Lists ALL boundaries (ACLs and grants) applied to an object. Only call this as an admin or curator of the object.
Examples
iex> list_on_object(object)
[%Boundary{}]
Lists ACLs applied to the given objects by the subject (current_user).
Examples
iex> list_on_objects_by_subject(objects, current_user)
%{object1_id => [%Acl{}], object2_id => [%Acl{}]}
Lists presets ACLs applied to the given objects.
Examples
iex> list_presets_on_objects(objects)
%{object_id => %Preset{}}
Lists subjects who have been granted a given verb on specified object(s).
Examples
iex> list_subjects_by_verb(objects, :read)
iex> list_subjects_by_verb(objects, :edit, false)
Removes the given ACLs from an object.
Examples
iex> remove_acls(object, acls)