TokenAuth

A Plug that provides Bearer authentication by checking the requests’ token matches the configured one.

Installation

{:token_auth, "~> 1.0.0"}

Usage

Plug it in your router or pipeline:

plug TokenAuth, [token: "youtoken", realm: "Authentication"]

If you use Confex, you can add the options to your configuration:

config :yourapp,
  token_auth: [
    token: {:system, "APP_TOKEN", "token"},
    realm: "Authentication"
  ]

And your router, you would write:

plug TokenAuth, Confex.get_env(:yourapp, :token_auth)