# Auth Shield [![Build Status](]( [![Coverage Status](](

Elixir authentication and authorization

AuthShield is an simple implementation that was created to be used with other frameworks (as Phoenix) or applications in order to provide an simple authentication and authorization management to the services.

## How to use

To install the dependency set `{:auth_shield, "~> 0.0.1"}` on your mix deps.

You can configure AuthX to use you database by setting on your `config.exs`:

config :auth_shield, AuthShield.Repo,
  database: "authx_ex_#{Mix.env()}",
  username: "postgres",
  password: "postgres",
  hostname: "localhost",
  port: 5432

The default session expiration is 15 minutes but you can change it setting on your `config.exs`:

config :auth_shield, AuthShield,
  # 15 minutes (in seconds)
  session_expiration: 60 * 15

To create a new user use:

    first_name: "Lucas",
    last_name: "Mesquita",
    email: "",
    password: "My_passw@rd2"

To login an user use:

    %{"email" => "", "password" => "Mypass@rd23"},
    remote_ip: "",
    user_agent: "Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0"

AuthShield has an authentication Plug (`AuthShield.Authentication.Plugs.AuthSession`) that can
be used to check if an user is authenticated or not in other endpoints.

If you are using phoenix and our Authentication Plug you should save the session in private on
your as the exemple bellow:

|> put_private(:session, session)
|> put_status(200)

## Documentation

You can check out the documentation [here](

### Extras

To know more about how we store the data and the authentication / authorization flow check links bellow:

- [Authentication architecture](;
- [Authorization architecture](;
- [Database architecture](;