SimpleTokenAuthentication

Usage

Phoenix Integration

  defmodule MyApp.Router
    use Phoenix.Router
    
    pipeline :api do
      plug SimpleTokenAuthentication
    end
    
    scope "/", MyApp do
      pipe_through :api
      get "/hello", HelloController, :hello
    end
  end

Installation

  1. Add simple_token_authentication to your list of dependencies in mix.exs:
  def deps do
    [{:simple_token_authentication, "~> 0.1.0"}]
  end
  1. Ensure simple_token_authentication is started before your application:
  def application do
    [applications: [:simple_token_authentication]]
  end
  1. Configure your token in config.exs:

    config :simple_token_authentication,
    token: "your-token-here",
    service_tokens: [
     service_a: "service-a-token",
     service_b: "service-b-token"
    ]
  2. Configure your connecting application to pass a token in the authorization header, e.g.:

    put_header("authorization", "your-token-here")

Notes