Why? 🤷
Frustrated by the complexity
and incomplete docs/tests
in existing auth solutions,
we built auth_plug to simplify our lives.
We needed a way to minimise
the number of steps
and amount of boilerplate code required
to add auth in our app(s).
auth_plug allows us to setup
auth in any Elixir/Phoenix
App in less than 2 minutes
and only 7 lines of code.
What?
A plug
a complete beginner can use to add auth to a
Phoenix App
and understand how it works.
No macros/behaviours to use (confuse).
No complex configuration.
No genservers or extra OTP apps.
Just a basic plug that uses Phoenix Sessions
and standards-based JSON Web Tokens (JWT).
Refreshingly simple. The way auth should be done.
Who? 👥
We built this plug for use in our products/services. It does exactly what we want it to and nothing more. It's tested, documented and open source the way all our code is. It's not yet a general purpose auth solution that anyone can use. If after reading through this you feel that this is something you would like to have in your own Elixir/Phoenix project, let us know!
How? 💡
1. Installation 📝
Add auth_plug
to your list of dependencies in mix.exs:
def deps do
[
{:auth_plug, "~> 0.8.0"}
]
end
Once you've saved the mix.exs file,
download the dependency with:
mix deps.get2. Get Your API Key 🔑
2.1 Save it as an Environment Variable
3. Protect a Route
Documentation
Documentation can be found at https://hexdocs.pm/auth_plug.
If anything is unclear, please open an issue: https://github.com/dwyl/auth_plug/issues
Recommended / Relevant Reading
If you are new to Elixir Plug, we recommend following: github.com/dwyl/elixir-plug-tutorial.
To understand JSON Web Tokens, read: https://github.com/dwyl/learn-json-web-tokens.