Expand description
Verifying what Fizzy posts to a webhook. Every delivery carries an X-Webhook-Signature
header: the hex HMAC-SHA256 of the raw body under the webhook’s secret.
use fizzy_sdk::webhooks::{SIGNATURE_HEADER, compute_signature, verify_signature};
let secret = "whsec_test";
let body = br#"{"event":"card.created"}"#;
let signature = compute_signature(body, secret);
assert!(verify_signature(body, &signature, secret));
assert!(!verify_signature(b"tampered", &signature, secret));
assert_eq!(SIGNATURE_HEADER, "X-Webhook-Signature");Constants§
- SIGNATURE_
HEADER - The header a delivery’s signature arrives in.
Functions§
- compute_
signature - The hex HMAC-SHA256 of
payloadundersecret, as Fizzy signs a delivery. - verify_
signature - Whether
signatureis the HMAC-SHA256 ofpayloadundersecret, compared in constant time. An empty secret or signature never verifies.