httpx-auth-awssigv4
This package provides utilities to add AWS Signature V4 authentication infrormation to calls made by python httpx library.
- Documentation: https://mmuppidi.github.io/httpx-auth-awssigv4
- GitHub: https://github.com/mmuppidi/httpx-auth-awssigv4
- PyPI: https://pypi.org/project/httpx-auth-awssigv4/
- MIT License
Installation
pip install httpx-auth-awssigv4
Usage
Basic Usage
This library has primarily been developed to help add authentication support to httpx library while making calls to REST API deployed using AWS API Gateway service. Will be extended in future to help with calling AWS services.
import httpx
from httpx_auth_awssigv4 import Sigv4Auth
# creating a callable for httpx library
auth = Sigv4Auth(
access_key="AWS_ACCESS_KEY_ID",
secret_key="AWS_SECRET_ACCESS_KEY",
service="execute-api",
region="us-east-1"
)
# Calling an API endpoint deployed using AWS API Gateway which has
# AWS_IAM set as authorization type
response = httpx.get(
url="https://<API ID>.execute-api.<Region>.amazonaws.com/prod/detials",
params={"username": "tstark"},
auth=auth
)
# Making a post call
response = httpx.get(
url="https://<API ID>.execute-api.<Region>.amazonaws.com/prod/details",
params={"username": "tstark"},
json={"mission": "avengers"},
auth=auth
)
With STS credentials
Sigv4Auth can be used with temporary credentials generated with tools like aws-sso-util.
import boto3
from httpx_auth_awssigv4 import Sigv4Auth
# fetch temporary credentials from AWS STS service
credentials = boto3.Session(profile_name="<profile>").get_credentials()
# creating a callable for httpx library
auth = Sigv4Auth(
access_key=credentials.access_key,
secret_key=credentials.secret_key,
token=credentials.token
service="execute-api",
region="us-east-1"
)
Sigv4Auth can also be used with temporary credentials from AWS STS.
import boto3
from httpx_auth_awssigv4 import Sigv4Auth
# role with `execute-api` permissions
ROLE_ARN="arn:aws:iam::<ACCOUNT ID>:role/<ROLE NAME"
# fetch temporary credentials from AWS STS service
credentials = boto3.client('sts').assume_role(
RoleArn=ROLE_ARN,
RoleSessionName="httpxcall"
)["Credentials"]
# creating a callable for httpx library
auth = Sigv4Auth(
access_key=credentials["AccessKeyId"],
secret_key=credentials["SecretAccessKey"],
token=credentials["SessionToken"]
service="execute-api",
region="us-east-1"
)
ToDo
- Add examples on usage along with API backend deployment instructions.
- Test the library with AWS services and add integration tests.
Credits
- This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
Metadata
Release files for httpx-auth-awssigv4 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| httpx-auth-awssigv4-0.1.4.tar.gz | 8.4 kB | Without provenance | Details for httpx-auth-awssigv4-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| httpx_auth_awssigv4-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for httpx_auth_awssigv4-0.1.4-py3-none-any.whl |
Total release size: 14.8 kB
Release files / httpx-auth-awssigv4-0.1.4.tar.gz
| Download URL | httpx-auth-awssigv4-0.1.4.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e8c87c9367896db6eea28a2195cb85a61ddf374cffab2070b2d044c3343625d
|
|
BLAKE2b-256 checksum How to use checksums |
c15bb5e80ff26240182b9d0dad19702676b3bb66cd3840ff2a2e3a5c3c10ee67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Release files / httpx_auth_awssigv4-0.1.4-py3-none-any.whl
| Download URL | httpx_auth_awssigv4-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e58ea5abf976cf4d6ef7643088e8e8002a557ca0520b076c56a9b9a14141bfae
|
|
BLAKE2b-256 checksum How to use checksums |
7311fdfd64af9ba9806e27e4290bd7e8d39eede24c5c15b4ed946bfd0846a895
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.12
|
Security for httpx-auth-awssigv4 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.