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.1.tar.gz (11.5 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.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aws_http_auth-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b7110e7ee46d5d001e417d3d8a4d2433019e5eba66059254e3ac20f98d50e3db
MD5 c48c998b4146f08a0c81c0f6061b5d4f
BLAKE2b-256 848a2b72e9b2f721eaa72e68731f9a57ff47de54f7bb7adadf2ac8111c18cda4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aws_http_auth-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08b518becf992cdfcc6ba6046b39e1476e63149736274ce7205085dcd8861645
MD5 da4f5519f72f0329717c31274a300bdb
BLAKE2b-256 7bb4e36dd26bb16701ac741261099974ac3d6885600d7d86260a7ba1f6547123

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