Concierge
Authentication solution for Phoenix and Elixir using Guardian.
Installation
If available in Hex, the package can be installed as:
Add concierge to your list of dependencies in
mix.exs:def deps do
[{:concierge, "~> 0.0.1"}]end
Ensure concierge is started before your application:
def application do
[applications: [:concierge]]end
Run
mix concierge.installAdd to
config/config.exsimport_config "concierge.exs"
Add to
web/web.exdef controller do
quote do # ... use Concierge.Controller endend
def view do
quote do # ... use Concierge.Helpers endend
Add to
web/router.ex
concierge at: "users", pipe_through: [:browser]- Start server and open [http://localhost:4000/users/sign_in]
Usage
Helpers
You will have current_user(@conn) and user_signed_in?(@conn) helpers in views.
Protecting endpoints
Concierge provides ensure_authenticated! controller filter. It accepts :only and :except options.
defmodule Example.PageController do
use Example.Web, :controller
ensure_authenticated! only: [:protected]
def index(conn, _params) do
render conn, "index.html"
end
def protected(conn, _params) do
render conn, "protected.html"
end
endTODO
- Confirmations
- OAuth
- ...