easy_auth

A Plug for HTTP basic authentication that's also easy to configure


License
MPL-2.0

Documentation

Easy auth

A Plug that provides basic http authentication and it's easy to configure.

Installation

{:easy_auth, "~> 1.1"}

Usage

Simply plug it in your router or pipeline:

plug EasyAuth, [username: "admin", password: "admin", realm: "Authentication"]

You can also set the options in your configuration:

config :yourapp,
  easy_auth: [
    username: "admin",
    password: "pizza",
    realm: "Authentication"
  ]

And your router, you would write:

plug EasyAuth, Application.get_env(:yourapp, :easy_auth)

If you use confex, you can do:

config :yourapp,
  easy_auth: [
    username: {:system, "APP_USERNAME", "admin"},
    password: {:system, "APP_PASSWORD", "admin"},
    realm: "Authentication"
  ]

and:

plug EasyAuth, Confex.get_env(:yourapp, :easy_auth)

However, since Plugs are compiled Confex will use the values available at compile-time.