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
@callback action_crud_mapping() :: keyword(Permit.Types.crud())
Link to this callback
authorization_module()
@callback authorization_module() :: module()
@callback except() :: [atom()]
@callback fallback_path() :: binary()
@callback handle_unauthorized(Permit.Types.conn()) :: Permit.Types.conn()
@callback id_param_name() :: Permit.Types.id_param_name()
@callback loader_fn() :: (... -> any()) | nil
@callback preload_resource_in() :: [atom()]
@callback resource_module() :: module()
@callback user_from_conn(Permit.Types.conn()) :: struct()