# GitlabHeaderAuth

[![build status](]( [![coverage report](](

A [plug]( to check that a request has a `X-GitLab-Auth` header, and the token in that header matches an expected value.

To set the expected value, add the following to your config: `config :gitlab_header_auth, :token, "THETOKEN"`. Remember to fetch this from the enviroment for production!

## Installation

The package can be installed by adding `gitlab_header_auth` to your list of dependencies in `mix.exs`:

def deps do
    {:gitlab_header_auth, "~> 1.0"}

## Usage

If using Phoenix, add `plug GitLabHeaderAuth` to the pipeline you want to authenticate - for example:

pipeline :api do
  plug :accepts, ["json"]
  plug GitLabHeaderAuth

If you haven't set the config correctly, the plug will halt the `conn` and tell you (by returning a JSON error). It will also halt and return if the auth fails.

## Example configuration

In `config/dev.exs` add the following:

config :gitlab_header_auth, :token, "DEVTOKEN"