Provides AWS authentication classes to be used with httpx2 authentication parameter
Project description
httpx2-aws-auth
Overview
This module provides AWS Signature Version 4 (SigV4) authentication for HTTPX2 (pydantic), supporting both synchronous and asynchronous authentication flows. It includes two main classes:
AwsSigV4Auth: For direct AWS credential authenticationAwsSigV4AssumeRoleAuth: For authentication using AWS IAM Role assumption
Features
- Simple integration with HTTPX2 (pydantic)
- 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 httpx2-aws-auth
Usage
Basic AWS Credentials Authentication
import httpx2
from httpx2_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 = httpx2.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
import httpx2
from httpx2_aws_auth import AwsSigV4AssumeRoleAuth
# Create AWS session
session = boto3.Session()
# Create an authenticated client with role assumption
client = httpx2.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
import httpx2
from httpx2_aws_auth import AwsSigV4AssumeRoleAuth
# Create async AWS session
async_session = aioboto3.Session()
# Create an authenticated async client with role assumption
async_client = httpx2.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 objectregion: AWS regionservice: AWS service name (default: 'execute-api')
AwsSigV4AssumeRoleAuth
region: AWS regionrole_arn: IAM Role ARN to assumeservice: AWS service name (default: 'execute-api')session: Synchronous boto3 sessionasync_session: Asynchronous aioboto3 sessionduration: Credential validity duration (default: 1 hour)refresh_buffer: Time before expiration to refresh credentials (default: 0 seconds)
Dependencies
- HTTPX2
- boto3 (for synchronous authentication)
- aioboto3 (for asynchronous authentication)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpx2_aws_auth-1.0.0.tar.gz.
File metadata
- Download URL: httpx2_aws_auth-1.0.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd37aff6936a438dbcbda2935989c37509c271626e2f148ca8cffda8e62e534
|
|
| MD5 |
f4e854fd69d8c3761e8adf81dff1dafd
|
|
| BLAKE2b-256 |
0681ac4830ecd8c5ad82751608cb3b9a691571d2ffd353f4c7cf5da2784b288b
|
Provenance
The following attestation bundles were made for httpx2_aws_auth-1.0.0.tar.gz:
Publisher:
release.yml on jammymalina/httpx2-aws-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
httpx2_aws_auth-1.0.0.tar.gz -
Subject digest:
8bd37aff6936a438dbcbda2935989c37509c271626e2f148ca8cffda8e62e534 - Sigstore transparency entry: 1608252442
- Sigstore integration time:
-
Permalink:
jammymalina/httpx2-aws-auth@14c54ea252455cb93fb993406d6212823cfd91db -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jammymalina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14c54ea252455cb93fb993406d6212823cfd91db -
Trigger Event:
release
-
Statement type:
File details
Details for the file httpx2_aws_auth-1.0.0-py3-none-any.whl.
File metadata
- Download URL: httpx2_aws_auth-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb3492c107a22f36b444b5be58612b907c7c31000aedd42115bfdcb89cae2570
|
|
| MD5 |
1c5a1131acc1cbf512299cb24911ea82
|
|
| BLAKE2b-256 |
bfeeb08862219cc2d757b75719a094ce2ba375f42b0bd927db2a281f1e690d92
|
Provenance
The following attestation bundles were made for httpx2_aws_auth-1.0.0-py3-none-any.whl:
Publisher:
release.yml on jammymalina/httpx2-aws-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
httpx2_aws_auth-1.0.0-py3-none-any.whl -
Subject digest:
eb3492c107a22f36b444b5be58612b907c7c31000aedd42115bfdcb89cae2570 - Sigstore transparency entry: 1608252532
- Sigstore integration time:
-
Permalink:
jammymalina/httpx2-aws-auth@14c54ea252455cb93fb993406d6212823cfd91db -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/jammymalina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14c54ea252455cb93fb993406d6212823cfd91db -
Trigger Event:
release
-
Statement type: