Authorization with Policy Wonk Tutorial
Policy Wonk is a lightweight authorization and resource loading library for any Plug or Phoenix application.
I wrote a tutorial walking through how to set it up and use it. Read it here.
Policy Wonk provides three main plugs.
-
PolicyWonk.LoadResource
loads resources into the conn’s assigns map. -
PolicyWonk.Enforce
evaluates a specified policy. It either continues or halts the plug chain depending on the policy result. -
PolicyWonk.EnforceAction
evaluates a policy for each incoming controller action in Phoenix.
Decisions are made before controller actions are called, isolating authorization logic, encouraging policy re-use, and reducing the odds of messing Auth-Z up as you develop your controllers.
Check it out here:
Read next Ecto Shortcuts - Common shortcut operations in ecto © (see license)