whatsapp integration
This commit is contained in:
parent
d077292bbc
commit
141ca9fda3
15 changed files with 578 additions and 1 deletions
13
backend/app/whatsapp_security.py
Normal file
13
backend/app/whatsapp_security.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import hashlib
|
||||
import hmac
|
||||
|
||||
|
||||
def verify_meta_signature(app_secret: str, raw_body: bytes, signature_header: str | None) -> bool:
|
||||
"""Validate X-Hub-Signature-256 from Meta webhook POSTs."""
|
||||
if not app_secret or not signature_header:
|
||||
return False
|
||||
if not signature_header.startswith("sha256="):
|
||||
return False
|
||||
expected = signature_header.removeprefix("sha256=")
|
||||
computed = hmac.new(app_secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
|
||||
return hmac.compare_digest(computed, expected)
|
||||
Loading…
Add table
Add a link
Reference in a new issue