SigV4 Request Generator

View Licence Agreement

class sosw.components.sigv4.AwsSigV4RequestGenerator(**kwargs)[source]

Signature Version 4 (SigV4) is the process to add authentication information to AWS API requests sent by HTTP. For security, most requests to AWS must be signed with an access key. The access key consists of an access key ID and secret access key, which are commonly referred to as your security credentials.

How Signature Version 4 works:

  1. Create a canonical request.

  2. Use the canonical request and additional metadata to create a string for signing.

  3. Derive a signing key from your AWS secret access key. Then use the signing key, and the string from the previous

  4. Add the resulting signature to the HTTP request in a header.

get_authorization_header(canonical_request, signed_headers)[source]

Create authorization header and add to request headers.

get_aws_sigv4_headers(request)[source]

Returns a dictionary containing the necessary headers for Amazon’s signature version 4 signing process.

get_canonical_headers(parsed_url)[source]

Create the canonical headers and signed headers. Header names must be trimmed and lowercase, and sorted in code point order from low to high. Note that there is a trailing \n.

static get_canonical_querystring(parsed_url)[source]

Create the canonical query string. According to AWS, by the end of this function our query string values must be URL-encoded (space=%20) and the parameters must be sorted by name.

static get_canonical_uri(parsed_url)[source]

Create canonical URI–the part of the URI from domain to query string (use ‘/’ if no path)

static get_headers_and_credential_date()[source]

Create a date for headers and the credential string

static get_payload_hash(request)[source]

Create payload hash. For GET requests, the payload is an empty string (“”)

get_signature_key()[source]

Key derivation functions. See: http://docs.aws.amazon.com/general/latest/gr/signature-v4-examples.html#signature-v4-examples-python