Controller plug to authorize actions based on permissions.
Usage in a controller:
plug VoileWeb.Plugs.Authorize, permissions: %{
new: ["metadata.manage"],
create: ["metadata.manage"],
edit: ["metadata.manage", "metadata.edit"],
update: ["metadata.manage", "metadata.edit"],
delete: ["metadata.manage"]
}If an action is not present in the permissions map, the plug is a no-op. The plug logs authorization attempts (user id, action, required permissions, and whether the attempt was allowed).