View Source Bonfire.Boundaries.Controlleds (Bonfire v0.9.11-social-beta.6)

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

add_acls(object, acl)

Adds the given ACL to an object.

Examples

iex> add_acls(object, :acl)
{:ok, %Controlled{}}

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

Returns a changeset for a Controlled with the given attributes.

Examples

iex> changeset(%Controlled{}, %{field: value})
%Ecto.Changeset{}

create(attrs)

Creates a Controlled record with the given attributes.

Examples

iex> create(%{field: value})
{:ok, %Controlled{}}

get_preset_on_object(object)

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

Examples

iex> get_preset_on_object(object)
%ACL{}

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

Grants a role to a subject for an object.

Examples

iex> grant_role(subject_id, object, :editor)
{:ok, %Grant{}}

list_acls_on_object(object, opts \\ [])

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{}]

list_grants_by_verbs(objects, verbs, value \\ true)

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)

list_on_object(object, opts \\ [])

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{}]

list_on_objects_by_subject(objects, current_user)

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{}]}

list_presets_on_objects(objects)

Lists presets ACLs applied to the given objects.

Examples

iex> list_presets_on_objects(objects)
%{object_id => %Preset{}}

list_q(opts \\ [])

list_subjects_by_verb(objects, verb, value \\ true)

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)

remove_acls(object, acls)

Removes the given ACLs from an object.

Examples

iex> remove_acls(object, acls)