diff --git a/CHANGELOG.md b/CHANGELOG.md index e3aa76d..602e7ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## Changelog +### v0.5.0 + +Fixes: + +- Handle normalization of path segments during signature computation (issue #6) + + The `normalize-path` tests in the AWS Signature V4 testsuite pass with + with fix. + ### v0.4.0 Fixes: diff --git a/README.md b/README.md index 99a3479..590a0fa 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,53 @@ end + [Module Doc](https://hexdocs.pm/sigaws) + [Plug built using this](https://hexdocs.pm/plug_sigaws) +## Examples + +### Signature to be passed as request headers + + url = "http://api.endpoint.host:5000/somthing?a=10&b=20" + headers = %{"header1" => "value1", "header2" => "value2"} + {:ok, %{} = sig_data, _} = + Sigaws.sign_req(url, + 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 = "http://api.endpoint.host:5000/somthing?a=10&b=20" + {:ok, %{} = sig_data, _} = + Sigaws.sign_url(url, + 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} = + Sigaws.Verify(conn.request_path, + 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. diff --git a/mix.exs b/mix.exs index 567fa33..cb7a481 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Sigaws.Mixfile do use Mix.Project - @version "0.4.0" + @version "0.5.0" @description """ An Elixir library to sign and verify HTTP requests using AWS Signature V4. """