make_webhook_validation_dependency
make_webhook_validation_dependency
make_webhook_validation_dependency
Build a FastAPI dependency that validates the X-SignalWire-Signature header (or the
X-Twilio-Signature alias) on a route. Attach the returned callable with Depends() to
enforce signature validation before your handler runs. The dependency reads and stashes
the raw request body, reconstructs the public URL, and calls
validate_webhook_signature. On an invalid signature it
aborts the request with HTTP 403; on success it returns None so the handler runs
normally.
When reconstructing the URL, the dependency honors the SWML_PROXY_URL_BASE environment
variable first (highest priority), then the X-Forwarded-Proto / X-Forwarded-Host
headers when trust_proxy is True, and finally the URL FastAPI sees.
Your Signing Key from the Dashboard. Required and non-empty — an empty value raises
ValueError at construction time.
If True, honor the X-Forwarded-Proto / X-Forwarded-Host headers when
reconstructing the URL. Defaults to False because proxy headers are spoofable.
Callable — an async FastAPI dependency that validates the signature header and aborts
with 403 on failure, returning None on success.