Add verify_webhook_signature helper for webhook authenticity#87
Open
roznawsk wants to merge 1 commit into
Open
Add verify_webhook_signature helper for webhook authenticity#87roznawsk wants to merge 1 commit into
roznawsk wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a public helper to verify Fishjam webhook authenticity by validating the x-fishjam-signature-256 HMAC-SHA256 signature against the raw request body, complementing the existing webhook decoding utilities in fishjam.
Changes:
- Added
verify_webhook_signature(body, signature, secret)usinghmac.compare_digestfor constant-time comparison. - Exported the helper from
fishjam.__init__alongside existing webhook helpers. - Added unit tests covering valid signatures (with/without
sha256=prefix) and common failure cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
fishjam/_webhook_notifier.py |
Implements verify_webhook_signature for validating signed webhook bodies. |
fishjam/__init__.py |
Re-exports verify_webhook_signature as part of the public SDK API. |
tests/test_webhook_notifier.py |
Adds test coverage for signature verification success/failure scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
verify_webhook_signature(body, signature, secret)tofishjam: verifies thex-fishjam-signature-256header (GitHub-stylesha256=<hex>HMAC-SHA256 of the raw body, prefix optional) usinghmac.compare_digestfor constant-time comparison. Exported next todecode_server_notifications; call it on the raw request body before decoding.Motivation and Context
Fishjam now signs webhook notifications. Without an SDK helper, users hand-roll verification with
==, which is timing-attackable. Same helper already added to the JS server SDK.Documentation impact
Types of changes
not work as expected)