Skip to main content

Webhook signature verification for Clavex Identity Platform

Project description

clavex-webhooks (Python)

Webhook signature verification for the Clavex Identity Platform.

Installation

pip install clavex-webhooks

Usage

from clavex_webhooks import Webhook, WebhookVerificationError

wh = Webhook("whsec_your_signing_secret")

# In your HTTP handler:
try:
    payload = wh.verify(
        body=request.body,                                # raw bytes or str
        signature=request.headers["X-Clavex-Signature"], # sha256=<hex>
    )
except WebhookVerificationError as exc:
    return Response(str(exc), status=400)

import json
event = json.loads(payload)
print(event["type"])  # e.g. "user.created"

Django / Flask example

# Django
@csrf_exempt
def webhook(request):
    wh = Webhook(settings.CLAVEX_WEBHOOK_SECRET)
    try:
        payload = wh.verify(request.body, request.headers.get("X-Clavex-Signature", ""))
    except WebhookVerificationError:
        return HttpResponse(status=400)
    handle_event(json.loads(payload))
    return HttpResponse(status=200)

API

Webhook(secret)

Create a verifier. secret may include the whsec_ prefix — it is stripped automatically.

webhook.verify(body, signature) → bytes

Verify and return the raw body. Raises WebhookVerificationError on failure.

verify(secret, signature, body) → bytes

Convenience one-shot function.

Signature format

Clavex sends X-Clavex-Signature: sha256=<HMAC-SHA256-hex> computed over the raw request body using your webhook secret.

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

clavex_webhooks-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

clavex_webhooks-1.0.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for clavex_webhooks-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e621123c57aa6a681c43513130583ecbbea74ff797439279204a62f2d810f20f
MD5 aa177378ea838a204187cf1ebfd2a189
BLAKE2b-256 23edcf89bb6360ff7064477590e1a41dae603575343081c492216a7db1b395e8

See more details on using hashes here.

Provenance

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

Publisher: release-pypi.yml on clavex-eu/clavex-sdk

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

File details

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

File metadata

File hashes

Hashes for clavex_webhooks-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73d173ac5429a212bd4055891041974881eb6d32a691c8198554ca30ef11dacd
MD5 a33ea6037c350bd470f657ba83734561
BLAKE2b-256 c51f60f5f0e5d85f895b839fdb73664d53194db3643fbf77b339962a01438760

See more details on using hashes here.

Provenance

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

Publisher: release-pypi.yml on clavex-eu/clavex-sdk

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