Bodyguard v2.1.0 Bodyguard.Plug.Authorize
Perform authorization in a Plug pipeline.
Options
policyrequired - the policy (or context) moduleactionrequired - the action to authorizeuser- a 1-arity function which accepts the connection and returns a user. If omitted, detaultsusertonilparams- params to pass to the authorization callbacksfallback- a fallback controller or plug to handle authorization failure. If specified, the plug is called and then the pipeline ishalted. If not specified, thenBodyguard.NotAuthorizedErrorraises directly to the router.
Examples
# Raise on failure
plug Bodyguard.Plug.Authorize, policy: MyApp.Blog, action: :update_posts,
user: &get_current_user/1
# Fallback on failure
plug Bodyguard.Plug.Authorize, policy: MyApp.Blog, action: :update_posts,
user: &get_current_user/1, fallback: MyApp.FallbackController
Summary
Functions
Callback implementation for Plug.call/2.
Callback implementation for Plug.init/1.