Gardien v0.0.2 Gardien

Gardien authorization.

Summary

Functions

Verify whether user is allowed to perform some action on a given resource

Verify whether action is allowed in a given context

Verify whether user is allowed to perform some action on a given resource

Verify whether action is allowed in a given context

Verify whether user is allowed to perform some action on a given resource

Functions

authorize(resource, conn)

Verify whether user is allowed to perform some action on a given resource.

user and action (controller action) are extracted from Plug.Conn struct. Returns {:ok, resource} when user is authorized and {:error, context} otherwise.

authorize(resource, action, context)

Verify whether action is allowed in a given context.

As a context you can pass the actual user or conn (Plug.Conn). Gardien will extract user from conn based on it’s gardien_user configuration. Returns {:ok, resource} when user is authorized and {:error, err_context} otherwise.

authorize!(resource, conn)

Verify whether user is allowed to perform some action on a given resource.

user and action (controller action) are extracted from Plug.Conn struct. Returns :ok when user is authorized and raises Gardien.AuthorizationError otherwise.

authorize!(resource, action, context)

Verify whether action is allowed in a given context.

As a context you can pass the actual user or conn (Plug.Conn). Gardien will extract user from conn based on it’s gardien_user configuration. Returns :ok when user is authorized and raises Gardien.AuthorizationError otherwise.

authorize?(resource, action, conn)

Verify whether user is allowed to perform some action on a given resource.

user is extracted from Plug.Conn struct. Returns true when user is authorized and false otherwise.