# Sigaws

An Elixir library to sign and verify HTTP requests using AWS Signature V4.

[![Inline docs](](

## Installation

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

def deps do
  [{:sigaws, "~> 0.1.0"}]

## Documentation

+ [Blog](
+ [Module Doc](
+ [Plug built using this](

## Examples

### Signature to be passed as request headers

    url = ""
    headers = %{"header1" => "value1", "header2" => "value2"}
    {:ok, %{} = sig_data, _} =
                      headers: headers,
                      region: "delta-quad",
                      service: "my-service",
                      access_key: "some-access-key",
                      secret: "some-secret")

    {:ok, resp} = HTTPoison.get(url, Map.merge(headers, sig_data))

### Signature to be passed in query string ("presigned" URL)

    url = ""
    {:ok, %{} = sig_data, _} =
                      body: :unsigned,
                      expires_in: 5 * 60,                 # 5 minutes
                      region: "delta-quad",
                      service: "my-service",
                      access_key: "some-access-key",
                      secret: "some-secret")

    presigned_url = Sigaws.Util.add_params_to_url(url, sig_data)

### Signature Verification

The verification process relies on a provider module that implements
`Sigaws.Provider` behavior. The provider is expected to supply the signing
key based on the information present in the context (primarily the access key).

    {:ok, %Sigaws.Ctxt{} = ctxt} =
        method: conn.method,
        params: conn.query_params,
        headers: conn.req_headers,
        body: get_raw_body(conn),
        provider: SigawsQuickStartProvider)

The above example is using the `sigaws_quickstart_provider` Hex package.
Check the blog listed earlier.

## Test Suite

Part of the tests in this package rely on AWS Signature Version 4 Test Suite.
This test suite should be downloaded and unpacked before running the tests.

mkdir -p test/testsuite
cd test/testsuite