Webhook signature verification for Fygaro
Project description
fygaro-webhook
Webhook signature verification for Fygaro — pure Python stdlib, zero runtime deps
This helper validates the Fygaro-Signature header of incoming webhooks.
It supports secret rotation (multiple active secrets), deterministic unit‑testing, and is ready for future
hash algorithms.
Installation
pip install fygaro-webhook
Requires Python ≥ 3.8.
Quick start
from fygaro.webhook import FygaroWebhookValidator
validator = FygaroWebhookValidator(
secrets=[
"my-primary-secret", # str or bytes
# "my-previous-secret", # include during rotation windows
],
# max_age=300, # optional (default = 5 min)
)
if not validator.verify_signature(
signature_header=request.headers["Fygaro-Signature"],
body=request.body, # raw bytes exactly as sent
):
raise ValueError("Invalid signature")
# …process JSON, return 200…
API reference
class FygaroWebhookValidator
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
secrets |
Sequence[str | bytes] |
✔ | — | One or more active webhook secrets. Provide all currently valid secrets during a rotation window. Each secret can be a UTF‑8 str or raw bytes. |
max_age |
int |
✖ | 300 |
Maximum allowable clock skew (in seconds) between the timestamp in the header and the server time. A low value mitigates replay attacks |
unsafe_skip_ts_validation |
bool |
✖ | False |
Test only. When True, the timestamp‑freshness check is skipped and a RuntimeWarning is emitted on instantiation. Never enable in production. |
validator.verify_signature(signature_header: str, body: bytes) -> bool
| Argument | Type | Description |
|---|---|---|
signature_header |
str |
The exact value of the incoming Fygaro‑Signature HTTP header. |
body |
bytes |
The unmodified request body (raw bytes). Do not .decode() or re‑serialize. |
Return value:
True— signature is valid and timestamp is withinmax_age(unless skipped).False— signature mismatch, stale timestamp, or malformed header.
Writing deterministic unit tests
To keep fixtures stable you can bypass the timestamp‑freshness check without touching production code:
validator = FygaroWebhookValidator(
secrets=[b"test-secret"],
unsafe_skip_ts_validation=True, # ← test‑only flag
)
The first instance created with unsafe_skip_ts_validation=True emits a
RuntimeWarning to remind you that this path is unsafe for live traffic.
License
MIT © Fygaro — support: support@fygaro.com
Changelog – @fygaro/webhook
[1.1.0] – 2025-07-10
Added
unsafe_skip_ts_validationconstructor flag that bypasses the timestamp-freshness check. Meant only for local/unit tests; not safe for production. Emits aRuntimeWarningthe first time an instance is created with the flag enabled, to minimise accidental misuse.
[1.0.0] – 2025-06-19
Added
- Initial release with
FygaroWebhookValidatorclass. - Supports multiple secrets & multiple
v1=hashes. - Constant-time compare and configurable timestamp window.
Project details
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 fygaro_webhook-1.1.2.tar.gz.
File metadata
- Download URL: fygaro_webhook-1.1.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ced65986b7422192c540c4b48fbfc50c4a9adcacf8add1f37ad460cfd93beb4
|
|
| MD5 |
1e268c69551ed532611cc3476fb87149
|
|
| BLAKE2b-256 |
adc8d0d9a447b7d93320c595815ee30165237a55e35fadf4535c922bee431a5f
|
Provenance
The following attestation bundles were made for fygaro_webhook-1.1.2.tar.gz:
Publisher:
webhook-python-release.yml on Fygaro/fygaro-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fygaro_webhook-1.1.2.tar.gz -
Subject digest:
3ced65986b7422192c540c4b48fbfc50c4a9adcacf8add1f37ad460cfd93beb4 - Sigstore transparency entry: 270990190
- Sigstore integration time:
-
Permalink:
Fygaro/fygaro-sdks@ad240c4183ecc481587889fa45a0e4eff89ebd97 -
Branch / Tag:
refs/tags/webhook-python-v1.1.2 - Owner: https://github.com/Fygaro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
webhook-python-release.yml@ad240c4183ecc481587889fa45a0e4eff89ebd97 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fygaro_webhook-1.1.2-py3-none-any.whl.
File metadata
- Download URL: fygaro_webhook-1.1.2-py3-none-any.whl
- Upload date:
- Size: 6.5 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 |
850f10d27a15db8466f8fd2ecd21c1dff7b7e8b9b833e7c98d3337bdd88e6d9f
|
|
| MD5 |
6d2bfe494c97b7e27a9050bbe20e282d
|
|
| BLAKE2b-256 |
5542577da06a601112f27ed31c448e58cb6361fefb2ff25c8f24f56622f4d9e1
|
Provenance
The following attestation bundles were made for fygaro_webhook-1.1.2-py3-none-any.whl:
Publisher:
webhook-python-release.yml on Fygaro/fygaro-sdks
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fygaro_webhook-1.1.2-py3-none-any.whl -
Subject digest:
850f10d27a15db8466f8fd2ecd21c1dff7b7e8b9b833e7c98d3337bdd88e6d9f - Sigstore transparency entry: 270990215
- Sigstore integration time:
-
Permalink:
Fygaro/fygaro-sdks@ad240c4183ecc481587889fa45a0e4eff89ebd97 -
Branch / Tag:
refs/tags/webhook-python-v1.1.2 - Owner: https://github.com/Fygaro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
webhook-python-release.yml@ad240c4183ecc481587889fa45a0e4eff89ebd97 -
Trigger Event:
push
-
Statement type: