Protego
Flexible authentication solution for Elixir/Phoenix with Guardian. it:
- Is inspired by Rails Devise;
- Is Plug based;
Protego is modular, so you can use:
- Authenticatable: Automates user authentication through POST requests, it handles hashing, storing and authenticating a user.
Getting Started
Add protego to your list of dependencies in mix.exs:
def deps do
[{:protego, "~> 0.0.1"}]
endConfigure Guardian
config :guardian, Guardian,
issuer: "MyApp.#{Mix.env}",
ttl: {1, :days},
verify_issuer: true,
serializer: Protego.Auth.GuardianSerializer,
secret_key: <secret_key_base>,Generate the user resource
mix phoenix.gen.model User users name:string email:string password_hash:stringConfigure your routes
defmodule MyApp.Router do
use MyApp.Web, :router
use Protego, :router
scope "/" do
pipe_through :browser
protego_for MyApp.Resource #ex: MyApp.User
end
endConfigure Protego (one for each resource )
config :protego, MyApp.User
authenticatable: true