Skip to main content

AWS Signature Version 4 signer for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_signing_sigv4


Swarmauri Signing SigV4

AWS Signature Version 4 (SigV4) signer and verifier that implements the ISigning interface for HTTP requests and raw byte payloads.

Features

  • Canonicalizes HTTP request envelopes according to AWS SigV4 rules
  • Derives SigV4 signing keys from AWS credentials and scope information
  • Supports both request signing and raw payload HMAC generation/verification
  • Returns structured signature metadata (scope, signed headers, canonical hash) for downstream Authorization headers

Security Notes

  • Requires valid AWS-style credentials (access_key, secret_key, optional session_token)
  • Verification requires access to the shared secret material; compare signatures externally when AWS performs verification
  • Payload canonicalization expects callers to supply the appropriate SHA-256 hash or the UNSIGNED-PAYLOAD marker

Installation

Install the package with your preferred Python packaging tool:

pip install swarmauri_signing_sigv4
uv pip install swarmauri_signing_sigv4
poetry add swarmauri_signing_sigv4

Usage

import asyncio
from swarmauri_signing_sigv4 import SigV4Signing


envelope = {
    "method": "GET",
    "uri": "/",
    "query": {"Action": ["ListUsers"], "Version": ["2010-05-08"]},
    "headers": {
        "host": "iam.amazonaws.com",
        "x-amz-date": "20150830T123600Z",
        "content-type": "application/x-www-form-urlencoded; charset=utf-8",
    },
    "payload_hash": "UNSIGNED-PAYLOAD",
    "amz_date": "20150830T123600Z",
    "scope": {"date": "20150830", "region": "us-east-1", "service": "iam"},
}

key = {"access_key": "AKIDEXAMPLE", "secret_key": "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"}


async def main() -> None:
    signer = SigV4Signing()
    signatures = await signer.sign_envelope(key, envelope)
    print(signatures[0]["signature"])


asyncio.run(main())

When verifying signatures you must provide the shared secret via opts["secret_key"] or require["secret_key"].

Byte payload signing

Use sign_bytes / verify_bytes when you only need a SigV4-derived HMAC:

payload = b"example"
opts = {"date": "20150830", "region": "us-east-1", "service": "iam"}
signatures = await signer.sign_bytes(key, payload, opts=opts)
assert await signer.verify_bytes(payload, signatures, opts={**opts, "secret_key": key["secret_key"]})

Entry Point

The signer registers under the swarmauri.signings entry point as SigV4Signing.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_signing_sigv4-0.1.1.dev37.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_signing_sigv4-0.1.1.dev37-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_signing_sigv4-0.1.1.dev37.tar.gz.

File metadata

  • Download URL: swarmauri_signing_sigv4-0.1.1.dev37.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_signing_sigv4-0.1.1.dev37.tar.gz
Algorithm Hash digest
SHA256 534eb3c4515cb04c89d4cd449e3e52edf9b282ad696a1adb25fa02c3150b690d
MD5 ad305dc174b278110de0dfb1d5e2aaa3
BLAKE2b-256 8a18d89f24f0e7b65b90a0ffc5ce8fab8ccf05b555c4a484dac215199b7f4d40

See more details on using hashes here.

File details

Details for the file swarmauri_signing_sigv4-0.1.1.dev37-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_signing_sigv4-0.1.1.dev37-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_signing_sigv4-0.1.1.dev37-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7f903b826b569352af1d76c5d507f5d54b89a94d93e36801ef726782d068f0
MD5 467028a17a53e8ddc0475990d9b8a10d
BLAKE2b-256 a66a1e0c77cee5fb80999d44c4d6e2c5860ffb68537eeab1174ec3ecd4fc7d49

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page