EndPointBlank.Plug.Authorized (end_point_blank_elixir v0.3.1)

Copy Markdown

Plug that enforces EndPointBlank authorization on a controller or pipeline.

Calls the EndPointBlank /api/authorize endpoint with the current request details. Returns a 401 JSON response if authorization fails.

Usage — controller plug

defmodule MyAppWeb.BooksController do
  use Phoenix.Controller
  plug EndPointBlank.Plug.Authorized
  ...
end

Usage — router pipeline

pipeline :api do
  plug :accepts, ["json"]
  plug EndPointBlank.Plug.Authorized
end