No project description provided
Project description
aiohttp_signer
This is an aiohttp client middleware, see also Client Middleware Cookbook, to add the digest and http message signatures.
Warning: Not all parts of RFC 9421 HTTP Message Signatures are implemented yet.
- pypi
- bovine-actor, uses aiohttp-signer for Fediverse GET/POST
History
This package was created as part of rewriting bovine. My goal with it being to separate the parts that are HTTP from the parts that are Fediverse and the parts that are cryptography.
Usage
The following illustrates the simplest usage of this package
import aiohttp
from aiohttp_signer import DigestMiddleware, Rfc9421Signer
async def make_post_request(
target_url: str,
data: dict,
key_id: str,
signer: Callable[[bytes], bytes]
):
async with aiohttp.ClientSession() as session:
await session.post(
target_url,
json=data,
middlewares=[
DigestMiddleware(),
Rfc9421Signer(key_id=key_id, signer=signer),
],
)
This will cause the message to contain the content-digest,
signature-input, and signature headers. Where the used
signature parameters are @method, @target-uri, and content-digest.
A sample implementation of signer would be
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.hazmat.primitives.asymmetric import ed25519
private_key_pem = b"""
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIJ+DYvh6SEqVTm50DFtMDoQikTmiCqirVv9mWG9qfSnF
-----END PRIVATE KEY-----
"""
def signer(x: bytes):
private_key = load_pem_private_key(private_key_pem, password=None)
assert isinstance(private_key, ed25519.Ed25519PrivateKey)
return private_key.sign(x)
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_signer-0.1.1.tar.gz.
File metadata
- Download URL: aiohttp_signer-0.1.1.tar.gz
- Upload date:
- Size: 118.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7bddd4a460b5afc7a8fd59fd1cb86e4829ffcec3be9ccdaf638c46cbbdbae8b
|
|
| MD5 |
6c2557e3857613dc3a62f6106b4ad8a7
|
|
| BLAKE2b-256 |
32a7795df98e0522728edf4ad7eef69ec4fa3a259f45e86935bdc89ffd2eb901
|
File details
Details for the file aiohttp_signer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: aiohttp_signer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa1438002574df7fa3ce6c5152dbc159b11c8f30f97764d96e4564819377ec6b
|
|
| MD5 |
31ea64202d66256a3091858e1bfd4884
|
|
| BLAKE2b-256 |
09b4f3e6ea2650e70217a76e326b60a13781421e5ef675c542a85650ac823cec
|