Verify bolthub gateway signatures on your origin — Flask, Django, FastAPI middleware
Project description
bolthub-verify
Verify bolthub gateway signatures on your origin server. Supports Flask, Django, and FastAPI out of the box.
Install
pip install bolthub-verify
Quick start (Flask)
from bolthub_verify import flask_hmac_middleware
app.before_request(flask_hmac_middleware("your-hmac-secret-from-dashboard"))
Quick start (FastAPI)
from fastapi import Depends
from bolthub_verify import fastapi_hmac_middleware
verify = fastapi_hmac_middleware("your-hmac-secret-from-dashboard")
@app.get("/protected")
async def protected(_=Depends(verify)):
return {"ok": True}
Quick start (Django)
# settings.py
MIDDLEWARE = [
"bolthub_verify.django_hmac_middleware",
# ...
]
BOLTHUB_HMAC_SECRETS = ["current-secret", "previous-secret"]
Secret rotation
Pass an array of secrets (current + previous) to support zero-downtime rotation:
flask_hmac_middleware(["new-secret", "old-secret"])
Low-level API
from bolthub_verify import verify_gateway_signature
result = verify_gateway_signature(
method="GET",
path="/v1/data",
signature=request.headers["X-Gateway-Signature"],
timestamp=request.headers["X-Gateway-Timestamp"],
nonce=request.headers["X-Gateway-Nonce"],
body="",
secrets="your-secret",
)
if not result.valid:
print(result.error)
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
bolthub_verify-0.1.0.tar.gz
(3.8 kB
view details)
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 bolthub_verify-0.1.0.tar.gz.
File metadata
- Download URL: bolthub_verify-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92aa6cf9ef251176d2e87465cd2aaf6eb4c59353aabdccb2af2a17f16a5a1855
|
|
| MD5 |
ac01e9063064ff22a49f6587a855c5cf
|
|
| BLAKE2b-256 |
e1cae1f2a190e3790287d85c8a964410e4b7cd4ed40fb516e6f2d3871d440817
|
File details
Details for the file bolthub_verify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bolthub_verify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1924ce253ba4f8e8af7af787e5fb2f5a8aca89efb2ec882f5031b68a49358e7b
|
|
| MD5 |
44ddb9960679217e06132d9947e788a0
|
|
| BLAKE2b-256 |
257c8b6c3e36599f414eac37706433d218b420c4ea4abddbdcfafc2e9d459bda
|