AuthShield v0.0.1 AuthShield.Resources.Permissions View Source

Permissions are used to define what a set of roles can do in the system.

We use this to implement and Role-based access control (RBAC).

RBAC is a policy-neutral access-control mechanism defined around roles and privileges.

The components of RBAC such as role-permissions and user-role relationships make it simple to perform user assignments.

This module implements an interface to deal with database transactions as inserts, updates, deletes, etc.

Link to this section Summary

Types

Transactional responses of failed

Transactional responses of success

Link to this section Types

Link to this type

failed_response()

View Source
failed_response() :: {:error, Ecto.Changeset.t()}

Transactional responses of failed

Link to this type

success_response()

View Source
success_response() :: {:ok, AuthShield.Resources.Schemas.Permission.t()}

Transactional responses of success

Link to this section Functions

Deletes a AuthShield.Resources.Schemas.Permission register.

Exemples:

  AuthShield.Resources.Permissions.delete(permission)

Deletes a AuthShield.Resources.Schemas.Permission register.

Similar to delete/1 but returns the struct or raises if the changeset is invalid.

Gets a AuthShield.Resources.Schemas.Permission register by its filters.

Exemples:

  AuthShield.Resources.Permissions.get_by(name: "can_create_users")

Gets a AuthShield.Resources.Schemas.Permission register by its filters.

Similar to get_by/1 but returns the struct or raises if the changeset is invalid.

Creates a new AuthShield.Resources.Schemas.Permission register.

Exemples:

  AuthShield.Resources.Permissions.insert(%{
    name: "can_create_users",
    description: "Has permission to create users on the system"
  })

Creates a new AuthShield.Resources.Schemas.Permission register.

Similar to insert/1 but returns the struct or raises if the changeset is invalid.

Returns a list of AuthShield.Resources.Schemas.Permission by its filters

Exemples:

  # Getting the all list
  AuthShield.Resources.Permissions.list()

  # Filtering the list by field
  AuthShield.Resources.Permissions.list(name: "can_create_users")
Link to this function

update(permission, params)

View Source
update(
  permission :: AuthShield.Resources.Schemas.Permission.t(),
  params :: map()
) :: success_response() | failed_response()

Updates a AuthShield.Resources.Schemas.Permission register.

Exemples:

  AuthShield.Resources.Permissions.update(permission, %{
    name: "can_update_users",
    description: "Has permission to update users on the system"
  })

Updates a AuthShield.Resources.Schemas.Permission register.

Similar to update/2 but returns the struct or raises if the changeset is invalid.