Skip to main content

Lightweight AWS SigV4 signing and HTTP authentication for httpx, requests, and raw HTTP clients—without the weight of boto3.

Project description

aws-http-auth

PyPI - Version PyPI - Python Version pre-commit.ci status

Lightweight AWS SigV4 signing and HTTP authentication for httpx, requests, and raw HTTP clients—without the weight of boto3.


Features

  • 🚀 Lightweight: No heavy dependencies like boto3—just pure AWS SigV4 signing
  • 🔗 Universal: Works with requests, httpx, and any HTTP client that supports auth handlers
  • 🔑 Flexible credentials: Load from AWS credentials file, environment variables, or provide directly
  • 🎯 Zero config: Automatically detects AWS regions and services from URLs
  • 🌐 Pyodide compatible: Works in browser environments with WebAssembly
  • 📦 Type safe: Full type hints for better development experience

Table of Contents

Installation

pip install aws-http-auth

Usage Examples

Using requests

from aws_http_auth.credentials import AWSCredentials
from aws_http_auth.http_auth import AWSV4SignerAuth
import requests

creds = AWSCredentials.from_ini_file("~/.aws/credentials")
auth = AWSV4SignerAuth(credentials=creds)

session = requests.Session()
session.auth = auth

response = session.request(
    method="POST",
    url="https://secretsmanager.us-east-1.amazonaws.com/",
    json={
        "SecretId": "MyTestDatabaseSecret",
    },
    headers={
        "Content-Type": "application/x-amz-json-1.1",
        "X-Amz-Target": "secretsmanager.GetSecretValue",
    },
)

Using httpx

from aws_http_auth.credentials import AWSCredentials
from aws_http_auth.http_auth import AWSV4SignerAuth
import httpx

creds = AWSCredentials.from_ini_file()
auth = AWSV4SignerAuth(credentials=creds)

async with httpx.AsyncClient(auth=auth) as client:
    response = await client.post(
        "https://secretsmanager.us-east-1.amazonaws.com/",
        json={
            "SecretId": "MyTestDatabaseSecret",
        },
        headers={
            "Content-Type": "application/x-amz-json-1.1",
            "X-Amz-Target": "secretsmanager.GetSecretValue",
        },
    )

Profile Selection

  • If no profile is specified, the library uses the AWS_PROFILE environment variable
  • If only one profile exists in the credentials file, it's used automatically
  • If multiple profiles exist and none is specified, an error is raised

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

aws-http-auth is distributed under the terms of the MIT license.

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

aws_http_auth-0.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

aws_http_auth-0.0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file aws_http_auth-0.0.2.tar.gz.

File metadata

  • Download URL: aws_http_auth-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aws_http_auth-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2a9fb6d25606e5fbe052a99a31160b9ae66291ae0face06f843557257330c71c
MD5 7fcf4422b04def603fde6b4b1c4159ec
BLAKE2b-256 87f0c3935fa9bdcdcc95150ffad63f0ee3ee7837e8d2040b21bdb145a7b7be75

See more details on using hashes here.

Provenance

The following attestation bundles were made for aws_http_auth-0.0.2.tar.gz:

Publisher: main.yaml on FlavioAmurrioCS/aws-http-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aws_http_auth-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: aws_http_auth-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aws_http_auth-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5aa013c7f54c5063a4098d7b8ee337a867a9cbe6156425b1370c496bda0f81da
MD5 634b29fa370e2b9b12a9985c745c992a
BLAKE2b-256 33d08e983a15ddd2ce44c711b1b939e9e56dba5cea48ef1005837f7834b8cf13

See more details on using hashes here.

Provenance

The following attestation bundles were made for aws_http_auth-0.0.2-py3-none-any.whl:

Publisher: main.yaml on FlavioAmurrioCS/aws-http-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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