schrockwell / bodyguard

Simple authorization conventions for Phoenix apps

Home Page:https://hexdocs.pm/bodyguard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add default config for Bodyguard.Plug.Authorize plug options

schrockwell opened this issue · comments

Example:

config :bodyguard, Bodyguard.Plug.Authorize,
  action: {Phoenix.Controller, :current_action},
  user: {App, :get_current_user}

Note we probably shouldn't/can't use anonymous functions in config files.

These would be merged in with the plug options, which would take precedence.

In Coherence, the function is Coherence.current_user(conn).
And I'm worry about the default action won't useful when the Bodyguard is in the context.
Buy the way defining defaults will be useful in productivity.

Can the fallback be configured too?

This is available in 2.4.0 now! See the docs for the correct syntax.

@jung-hunsoo yes, the default value for any option can be configured