Skip to content

v0.0.1

Compare
Choose a tag to compare
@nateprewitt nateprewitt released this 24 May 02:51
· 8 commits to main since this release

0.0.1 (2024-05-23)

Features

  • Added SigV4Signer to sign arbitrary requests sychronously.
  • Added AsyncSigV4Signer to sign arbitrary requests asychronously.
  • Added example SigV4Auth for integrating directly with Requests’
    auth parameter.
  • Added SigV4Signer for integrating with the AIOHTTP request
    workflow.
  • Added SigV4Curl for generating signed curl commands.

Getting Started

The general premise of the library is to allow portable SigV4 signing implementations that can be integrated with any HTTP Client using Python. With the release of 0.0.1, we support signing for AIOHTTP, Curl, and Requests through their native auth interfaces. These are intended to serve as proofs of concept for how the signing library can be ported elsewhere for easy integration with existing applications without the need for a whole SDK.

from os import environ

import requests

from examples import requests_signer
from aws_sdk_signers import SigV4SigningProperties, AWSCredentialIdentity

SERVICE="lambda"
REGION="us-west-2"

# A GET request to this URL performs a "ListFunctions" invocation.
# Full API documentation can be found here:
# https://docs.aws.amazon.com/lambda/latest/api/API_ListFunctions.html
URL='https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/'

# Set up our signing properties and identity
signing_properties = SigV4SigningProperties(region=REGION, service=SERVICE)
identity = AWSCredentialIdentity(
        access_key_id=environ["AWS_ACCESS_KEY_ID"],
        secret_access_key=environ["AWS_SECRET_ACCESS_KEY"],
        session_token=environ.get("AWS_SESSION_TOKEN"),
)

# Configure the auth class for signing
sigv4_auth = requests_signer.SigV4Auth(signing_properties, identity)

>>> r = requests.get(URL, auth=sigv4_auth)
>>> print(r.json())
{'Functions': [{'Description': '', 'TracingConfig': {'Mode': 'PassThrough'}, 'VpcConfig': ... 'NextMarker': None}