View Source Bonfire.Boundaries.Controlleds (Bonfire v0.9.10-classic-beta.169)

An object is linked to one or more Acls 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{}}
Link to this function

changeset(c \\ %Controlled{}, attrs)

View Source

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{}}
Link to this function

get_preset_on_object(object)

View Source

Gets a preset ACL applied to an object, if any.

Examples

iex> get_preset_on_object(object)
%ACL{}
Link to this function

grant_role(subject_id, object, role, opts \\ [])

View Source

Grants a role to a subject for an object.

Examples

iex> grant_role(subject_id, object, :editor)
{:ok, %Grant{}}
Link to this function

list_acls_on_object(object, opts \\ [])

View Source

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{}]
Link to this function

list_grants_by_verbs(objects, verbs, value \\ true)

View Source

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)
Link to this function

list_on_object(object, opts \\ [])

View Source

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{}]
Link to this function

list_on_objects_by_subject(objects, current_user)

View Source

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{}]}
Link to this function

list_presets_on_objects(objects)

View Source

Lists presets ACLs applied to the given objects.

Examples

iex> list_presets_on_objects(objects)
%{object_id => %Preset{}}
Link to this function

list_subjects_by_verb(objects, verb, value \\ true)

View Source

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)
Link to this function

remove_acls(object, acls)

View Source

Removes the given ACLs from an object.

Examples

iex> remove_acls(object, acls)