https://github.com/camirmas/bartender
:cocktail: JWT authentication using Absinthe + Guardian
https://github.com/camirmas/bartender
authentication elixir graphql phoenix-framework
Last synced: 10 months ago
JSON representation
:cocktail: JWT authentication using Absinthe + Guardian
- Host: GitHub
- URL: https://github.com/camirmas/bartender
- Owner: camirmas
- License: mit
- Created: 2018-04-30T07:33:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-30T08:25:36.000Z (over 7 years ago)
- Last Synced: 2025-03-16T19:37:50.544Z (11 months ago)
- Topics: authentication, elixir, graphql, phoenix-framework
- Language: Elixir
- Size: 9.77 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# :cocktail: Bartender
> JWT authentication using [Absinthe](https://github.com/absinthe-graphql/absinthe) + [Guardian](https://github.com/ueberauth/guardian)
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `bartender` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:bartender, "~> 0.1.0"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/bartender](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.
```elixir
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](https://hexdocs.pm/absinthe/context-and-authentication.html#content) for more info.