# TwilioAuth

This library implements validation for incoming requests from
Twilio, per the spec outlined at:

## Installation

The package can be installed from hex by adding the following
to your project's `mix.exs`:

  def deps do
    [{:twilio_auth, "~> 0.3.0"}]

## Use

`TwilioAuth` is implemented as a [Plug](,
and can be activated by including it as part of an existing pipeline.

For example, in a Phoenix router:


defmodule MyRouter do
  use Phoenix.Router

  pipeline :my_pipe do
    plug TwilioAuth, auth_token: YOUR_AUTH_TOKEN

  scope "/twilio" do
    pipe_through :my_pipe

    # ...

Importantly, `TwilioAuth` depends on query and body params having already
been fetched, so should always be used after `Plug.Parsers`.

The plug has two configuration options:

auth_token # authentication token provided by Twilio for your app's use
           # String.t | {atom(), atom()}
enabled    # boolean controlling whether auth is on (`true` by default)

`auth_token` allows either a string argument, or a 2-tuple that will be
evaluated at runtime to get an environment variable off of `Application`.


# in config.exs
config :twilio_auth, auth_token: YOUR_AUTH_TOKEN

# in router
plug TwilioAuth, auth_token: {:twilio_auth, :auth_token}