Skip to main content

Provides AWS authentication classes to be used with httpx authentication parameter

Project description

httpx-aws-auth

Overview

This module provides AWS Signature Version 4 (SigV4) authentication for HTTPX, supporting both synchronous and asynchronous authentication flows. It includes two main classes:

  • AwsSigV4Auth: For direct AWS credential authentication
  • AwsSigV4AssumeRoleAuth: For authentication using AWS IAM Role assumption

Features

  • Simple integration with HTTPX
  • Support for both synchronous and asynchronous authentication
  • AWS SigV4 signing for API requests
  • IAM Role assumption with configurable duration
  • Credential expiration and automatic refresh
  • Flexible configuration options

Installation

Install the package using pip:

pip install httpx-aws-auth

Usage

Basic AWS Credentials Authentication

import httpx
from httpx_aws_auth import AwsSigV4Auth, AwsCredentials

# Create AWS credentials
credentials = AwsCredentials(
    access_key='YOUR_ACCESS_KEY',
    secret_key='YOUR_SECRET_KEY'
)

# Create an authenticated client
client = httpx.Client(
    auth=AwsSigV4Auth(
        credentials=credentials,
        region='us-west-2',
        service='execute-api'
    )
)

# Make a request
response = client.get('https://your-api-endpoint.com')

IAM Role Assumption (Synchronous)

import boto3
from httpx_aws_auth import AwsSigV4AssumeRoleAuth

# Create AWS session
session = boto3.Session()

# Create an authenticated client with role assumption
client = httpx.Client(
    auth=AwsSigV4AssumeRoleAuth(
        region='us-west-2',
        role_arn='arn:aws:iam::123456789012:role/YourRole',
        session=session,
        duration=timedelta(hours=1)
    )
)

# Make a request
response = client.get('https://your-api-endpoint.com')

IAM Role Assumption (Asynchronous)

import aioboto3
from httpx_aws_auth import AwsSigV4AssumeRoleAuth

# Create async AWS session
async_session = aioboto3.Session()

# Create an authenticated async client with role assumption
async_client = httpx.AsyncClient(
    auth=AwsSigV4AssumeRoleAuth(
        region='us-west-2',
        role_arn='arn:aws:iam::123456789012:role/YourRole',
        async_session=async_session,
        duration=timedelta(hours=1)
    )
)

# Make an async request
async with async_client as client:
    response = await client.get('https://your-api-endpoint.com')

Configuration Options

AwsSigV4Auth

  • credentials: AWS credentials object
  • region: AWS region
  • service: AWS service name (default: 'execute-api')

AwsSigV4AssumeRoleAuth

  • region: AWS region
  • role_arn: IAM Role ARN to assume
  • service: AWS service name (default: 'execute-api')
  • session: Synchronous boto3 session
  • async_session: Asynchronous aioboto3 session
  • duration: Credential validity duration (default: 1 hour)
  • refresh_buffer: Time before expiration to refresh credentials (default: 0 seconds)

Dependencies

  • HTTPX
  • boto3 (for synchronous authentication)
  • aioboto3 (for asynchronous authentication)

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

httpx_aws_auth-3.0.1.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

httpx_aws_auth-3.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file httpx_aws_auth-3.0.1.tar.gz.

File metadata

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

File hashes

Hashes for httpx_aws_auth-3.0.1.tar.gz
Algorithm Hash digest
SHA256 4280ebfb5b4438f33bae59df5cc61d939ff832f34d6d5daadf546ab3d3c424cf
MD5 866dc2083077fd8d03e60a958c7283f0
BLAKE2b-256 db1ada6e3a9c6b362bb3658e4b8ecd34e7c28c7ab6dd6efcf9c24bec59da524a

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_aws_auth-3.0.1.tar.gz:

Publisher: release.yml on jammymalina/httpx-aws-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 httpx_aws_auth-3.0.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for httpx_aws_auth-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70d99aeac9e43fdd84f1cac1c8ba57f6501d2cdd29de15896b2b0aea3b222d34
MD5 7cef864367df149d9a56cbafef8f2694
BLAKE2b-256 9e854b1d23f66fa3d4f20f7b3667576cec3bdc2ea616a9a5a1ed59cb6aced815

See more details on using hashes here.

Provenance

The following attestation bundles were made for httpx_aws_auth-3.0.1-py3-none-any.whl:

Publisher: release.yml on jammymalina/httpx-aws-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