calcinator v1.0.0 Calcinator.Authorization behaviour

Behaviour for Calcinator.Resources.t authorization_module

Summary

Types

The actions that must be handled by can?/3, filter_associations_can/3, and filter_can/3

The subject that is trying to do the action and needs to be authorized by authorization_module

The target of the subject’s action

Callbacks

Checks whether subject (from Calcinator.Resources.t subject) can perform action on target

Reduces associations on target to only those where can?(subject, action, associated_ascent) is true

Reduces targets to only those elements where can?(subject, action, targets_element) is true

Types

action()
action() :: :create | :delete | :index | :update | :show

The actions that must be handled by can?/3, filter_associations_can/3, and filter_can/3.

subject()
subject() :: term

The subject that is trying to do the action and needs to be authorized by authorization_module

target()
target() :: term

The target of the subject’s action

Callbacks

can?(subject, action, target)
can?(subject, action, target) :: boolean

Checks whether subject (from Calcinator.Resources.t subject) can perform action on target.

filter_associations_can(target, subject, action)
filter_associations_can(target, subject, action) :: target

Reduces associations on target to only those where can?(subject, action, associated_ascent) is true.

filter_can(targets, subject, action)
filter_can(targets :: [target], subject, action) :: [target]

Reduces targets to only those elements where can?(subject, action, targets_element) is true.