Permit.ControllerAuthorization behaviour (permit v0.0.1)

Injects authorization plug (Permit.Plug), allowing to provide its options either directly in options of use, or as overridable functions.

Example:

# my_app_web.ex
def controller do
  use Permit.ControllerAuthorization,
    authorization_module: MyApp.Authorization,
    fallback_path: "/unauthorized"
end

# your controller module
defmodule MyAppWeb.PageController do
  use MyAppWeb, :live_view

  @impl true
  def resource_module, do: MyApp.Item

  # you might or might not want to override something here
  @impl true
  def fallback_path: "/foo"
end

Link to this section Summary

Link to this section Callbacks

Link to this callback

action_crud_mapping()

(optional)
@callback action_crud_mapping() :: keyword(Permit.Types.crud())
Link to this callback

authorization_module()

@callback authorization_module() :: module()
Link to this callback

except()

(optional)
@callback except() :: [atom()]
Link to this callback

fallback_path()

(optional)
@callback fallback_path() :: binary()
Link to this callback

handle_unauthorized(conn)

(optional)
@callback handle_unauthorized(Permit.Types.conn()) :: Permit.Types.conn()
Link to this callback

id_param_name()

(optional)
@callback id_param_name() :: Permit.Types.id_param_name()
Link to this callback

loader_fn()

(optional)
@callback loader_fn() :: (... -> any()) | nil
Link to this callback

preload_resource_in()

(optional)
@callback preload_resource_in() :: [atom()]
Link to this callback

resource_module()

(optional)
@callback resource_module() :: module()
Link to this callback

user_from_conn(conn)

(optional)
@callback user_from_conn(Permit.Types.conn()) :: struct()