Lotus.Web.Resolver behaviour (Lotus Web v0.14.5)

View Source

Behavior for customizing Lotus Web dashboard access and functionality.

Summary

Callbacks

Determine the access level for a user.

Extract the current user from a Plug.Conn when the dashboard mounts.

Types

access_level()

@type access_level() :: :all | :read_only | :forbidden | {:forbidden, String.t()}

user()

@type user() :: nil | map() | struct()

Callbacks

resolve_access(user)

(optional)
@callback resolve_access(user :: user()) :: access_level()

Determine the access level for a user.

Based on the user returned from resolve_user/1, this callback determines what operations the user can perform in the Lotus dashboard.

Return Values

  • :all - Full access to all Lotus features
  • :read_only - Can only view and run queries, no modifications
  • :forbidden - No access
  • {:forbidden, path} - Redirect to the given path

resolve_user(conn)

(optional)
@callback resolve_user(conn :: Plug.Conn.t()) :: user()

Extract the current user from a Plug.Conn when the dashboard mounts.

This callback is invoked when the Lotus dashboard is accessed. The returned user value will be passed to other callbacks for access control decisions.