Provides AWS authentication middlewares to be used with aiohttp
Project description
aiohttp-aws-auth
Overview
This module provides AWS Signature Version 4 (SigV4) authentication for aiohttp through two primary middleware classes:
AwsSigV4Auth: For direct AWS credential authenticationAwsSigV4AssumeRoleAuth: For authentication using AWS IAM Role assumption
Features
- Simple integration with aiohttp
- 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 aiohttp-aws-auth
Usage
Basic AWS Credentials Authentication
import aiohttp
from aiohttp_aws_auth import AwsSigV4Auth, AwsCredentials
# Create AWS credentials
credentials = AwsCredentials(
access_key='YOUR_ACCESS_KEY',
secret_key='YOUR_SECRET_KEY'
)
# Create an authentication middleware
aws_auth_middleware = AwsSigV4Auth(
credentials=credentials,
region='us-west-2',
service='execute-api',
)
# Make a request
async with ClientSession(middlewares=(aws_auth_middleware,)) as session:
resp = await session.get("https://your-api-endpoint.com")
IAM Role Assumption
import aioboto3
from aiohttp_aws_auth import AwsSigV4AssumeRoleAuth
# Create async AWS session
session = aioboto3.Session()
# Create an authentication middleware
aws_auth_middleware = AwsSigV4AssumeRoleAuth(
region='us-west-2',
role_arn='arn:aws:iam::123456789012:role/YourRole',
session=session,
duration=timedelta(hours=1),
)
# Make an async request
async with ClientSession(middlewares=(aws_auth_middleware,)) as session:
resp = await session.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
- aiohttp
- aioboto3 (only needed when using AwsSigV4AssumeRoleAuth)
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 aiohttp_aws_auth-0.0.1.tar.gz.
File metadata
- Download URL: aiohttp_aws_auth-0.0.1.tar.gz
- Upload date:
- Size: 64.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1e51084e7955fd20f0ed64ebe0b19d613c77e3c88d03ed4d7964d0197959393
|
|
| MD5 |
0bc5635e909bdb6452f20902dcb556b6
|
|
| BLAKE2b-256 |
23b99e1b26d41c12aa3065f6b2bd81d7664db57bd4a7b3875eaa93852baf583d
|
Provenance
The following attestation bundles were made for aiohttp_aws_auth-0.0.1.tar.gz:
Publisher:
release.yml on jammymalina/aiohttp-aws-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiohttp_aws_auth-0.0.1.tar.gz -
Subject digest:
c1e51084e7955fd20f0ed64ebe0b19d613c77e3c88d03ed4d7964d0197959393 - Sigstore transparency entry: 264038490
- Sigstore integration time:
-
Permalink:
jammymalina/aiohttp-aws-auth@6bce78b1bdb4d8d85f62945147180460752727cf -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/jammymalina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce78b1bdb4d8d85f62945147180460752727cf -
Trigger Event:
release
-
Statement type:
File details
Details for the file aiohttp_aws_auth-0.0.1-py3-none-any.whl.
File metadata
- Download URL: aiohttp_aws_auth-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e1247cbecb40cca26052c3e2dfd16e28300818ac23c666477d2f13315131ff9
|
|
| MD5 |
17f03a3025b5b67c56e9ec3b83737956
|
|
| BLAKE2b-256 |
bc475b4540a8e909aafaa2d77b4bc47d06927002c05bde1d7b84d7f3a7f00041
|
Provenance
The following attestation bundles were made for aiohttp_aws_auth-0.0.1-py3-none-any.whl:
Publisher:
release.yml on jammymalina/aiohttp-aws-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiohttp_aws_auth-0.0.1-py3-none-any.whl -
Subject digest:
5e1247cbecb40cca26052c3e2dfd16e28300818ac23c666477d2f13315131ff9 - Sigstore transparency entry: 264038503
- Sigstore integration time:
-
Permalink:
jammymalina/aiohttp-aws-auth@6bce78b1bdb4d8d85f62945147180460752727cf -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/jammymalina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6bce78b1bdb4d8d85f62945147180460752727cf -
Trigger Event:
release
-
Statement type: