Skip to main content

UpSec Webhook signature verification SDK for Python

Project description

upsec-webhook

Official Python SDK for verifying UpSec webhook signatures.

Installation

pip install upsec-webhook

Quick Start

from upsec import verify_signature

is_valid = verify_signature(
    payload=request.get_data(),
    secret=os.environ["WEBHOOK_SECRET"],
    signature=request.headers.get("X-Hub-Signature-256", ""),
)

Flask Decorator

from upsec.middleware import flask_webhook

@app.route("/webhook", methods=["POST"])
@flask_webhook(secret=os.environ["WEBHOOK_SECRET"])
def handle_webhook():
    # Signature verified automatically
    return {"ok": True}

API

verify_signature(payload, secret, signature, algorithm="sha256")

Returns True if the HMAC signature is valid. Uses constant-time comparison.

sign_payload(payload, secret, algorithm="sha256")

Returns a signed header string like sha256=<hex>. Useful for testing.

flask_webhook(secret, header, algorithm)

Flask decorator that auto-rejects invalid signatures with 401.

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

upsec_webhook-1.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

upsec_webhook-1.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file upsec_webhook-1.0.0.tar.gz.

File metadata

  • Download URL: upsec_webhook-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for upsec_webhook-1.0.0.tar.gz
Algorithm Hash digest
SHA256 318b1babbdbd53a4e027750eec3b457028f30da1a46614577afab36266c6c9a9
MD5 40382f2f79e534b8313936d58b1fc4fb
BLAKE2b-256 49c53561ff56ca25031c5ba3332eee0e970e15749d92eebcb7e8a5f4c4d4a232

See more details on using hashes here.

Provenance

The following attestation bundles were made for upsec_webhook-1.0.0.tar.gz:

Publisher: publish-python.yml on selmansenol/upsec-594fe05e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file upsec_webhook-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: upsec_webhook-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for upsec_webhook-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97f9aca968d3215a87923f47bf57530806420cd6bc0c0acf65772d4c7604da28
MD5 739fc40828f8c14423961f2906d8234b
BLAKE2b-256 9ef7c0b28c252695c9cfda8cd044dfdeac47a6401af488f9e8656cad87ce2b1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for upsec_webhook-1.0.0-py3-none-any.whl:

Publisher: publish-python.yml on selmansenol/upsec-594fe05e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page