:cocktail: Bartender

JWT authentication using Absinthe + Guardian

Installation

If available in Hex, the package can be installed by adding bartender to your list of dependencies in mix.exs:

def deps do
  [
    {:bartender, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/bartender.

Usage

You can call Bartender.Plug explicitly with Bartender.Plug.call(conn, MyApp.Guardian)

If using in Phoenix, or any other app that uses Router, establish the Plug like so.

defmodule MyApp.Router do
  use MyApp, :router

  pipeline :api do
    plug :accepts, ["json"]
    plug Bartender.Plug, MyApp.Guardian
  end
end

This Plug makes use of Absinthe.Plug, inserting the verified resource (in this case, a current_user) into the Connection, which can then be accessed from a Resolver. See the Absinthe docs for more info.