This is the working example of ** Guardian Authentication ** implemented using the ** Postgresql ** database. In this example I am using the default
localhost for live authentication for live database.
- User Registrations Listing Editing and Deleting
- User Sessions Creation/Deletion
- If the new user is created, a session is automatically created and treating that user as a logged in user automatically.
- Authentication Url Redirection.
If the user try to visit the unauthorized urls with out logging in then he is redirected to login page. If he already logged in and trying to visit login page, if the token is still exists, he is redirected to authenticated users.
The following are the versions used at the time of writing this template.
Authentication Elixir Modules
Guardian ~> 0.14
bcrypt_elixir ~> 1.0
comeonin ~> 4.0
** NOTE **
For bcrypt_elixir version 1.0, you need to be using
bcrypt_elixir version 0.12, if you use the older version of the
You can use this as an Authentication Template or Boilerplate and start focussing on your development instead of spending time in writing
user signin and signout.
Just clone it using the url
https://github.com/blackode/guardian_auth.git and change the MODULE NAMES and APP_NAMES according to your project.
To start your Phoenix server:
- Install dependencies with
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
- Install Node.js dependencies with
cd assets && npm install
- Start Phoenix endpoint with
Now you can visit
localhost:4000 from your browser.