Gardien v1.0.0 Gardien.Policy protocol

Protocol used by Gardien authorization functions.

Implementation example (see Gardien.Authorize for implementation alternatives):

defimpl Gardien.Policy, for: MyApplication.Post do
  def authorize?(post, :edit, user) do
    post.user_id == user.id
  end

  # other rules ...
end

Summary

Functions

Receives resource (that needs to be authorized), action and user. authorize?/3 should return true or false

Types

t :: term

Functions

authorize?(resource, action, user)

Receives resource (that needs to be authorized), action and user. authorize?/3 should return true or false.