txt: ## dist_zef-bradclawsie-WebService-AWS-Auth-V4.md
  [![](https://img.shields.io/badge/License-BSD-yellow.svg)](https://opensource.org/licenses/BSD-2-Clause)
  [![ci](https://github.com/bradclawsie/Net-IP-Parse/workflows/test/badge.svg)](https://github.com/bradclawsie/Webservice-AWS-Auth-V4/actions)
  
  # WebService::AWS::Auth::V4
  
  A library for AWS Auth V4 methods.
  
  ## DESCRIPTION
  
  AWS employs a set of signing processes in order to create authorized requests. This
  library provides an implementation of the v4 signing requirements as described here:
  
  <http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html>
  
  This library conforms to a set of published conformance tests that AWS publishes
  here:
  
  <http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html>
  
  This library passes these tests. This is not a general purpose library
  for using AWS services, although v4 signing is a requirement for any
  toolkit that provides an AWS API, so this library may be useful
  as a foundation for an AWS API.
  
  ## SYNOPSIS
  
  ```
  use v6;
  use Test;
  use WebService::AWS::Auth::V4;
  
  my constant $service = 'iam';
  my constant $region = 'us-east-1';
  my constant $secret = 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY';
  my constant $access_key = 'AKIDEXAMPLE';
  my constant $get = 'GET';
  my constant $aws_sample_uri = 'https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08';
  my Str @aws_sample_headers = "Host:iam.amazonaws.com",
     "Content-Type:application/x-www-form-urlencoded; charset=utf-8",
     "X-Amz-Date:20150830T123600Z";
  
  my $v4 = WebService::AWS::Auth::V4.new(method => $get, body => '', uri => $aws_sample_uri, headers => @aws_sample_headers, region => $region, service => $service, secret => $secret, access_key => $access_key);
  
  my $cr = $v4.canonical_request();
  my $cr_sha256 = WebService::AWS::Auth::V4::sha256_base16($cr);
  is WebService::AWS::Auth::V4::sha256_base16($cr), 'f536975d06c0309214f805bb90ccff089219ecd68b2577efef23edd43b7e1a59', 'match aws test signature for canonical request';
  
  is $v4.string_to_sign, "AWS4-HMAC-SHA256\n20150830T123600Z\n20150830/us-east-1/iam/aws4_request\nf536975d06c0309214f805bb90ccff089219ecd68b2577efef23edd43b7e1a59", 'string to sign';
  
  is $v4.signature, '5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7', 'signature';
  
  is $v4.signing_header(), 'Authorization: AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7', 'authorization header';
  
  ```
  
  ## AUTHOR
  
  Brad Clawsie (zef:bradclawsie, email:brad@b7j0c.org)
  
  ## Notice
  
  This repository was uploaded via `fez` under the username `b7j0c`,
  and later `bradclawsie`. This change was made so the username would match
  Github. Sorry for any confusion.
  
  ## Installation
  
  ```
  zef install Webservice::AWS::Auth::V4
  
  ```
  