diff --git a/src/docs/product/integrations/integration-platform/webhooks.mdx b/src/docs/product/integrations/integration-platform/webhooks.mdx index f5cbe2a8d4fba..f7e5cfb645142 100644 --- a/src/docs/product/integrations/integration-platform/webhooks.mdx +++ b/src/docs/product/integrations/integration-platform/webhooks.mdx @@ -65,7 +65,7 @@ import hashlib import hmac import json -expected_digest = request.headers['sentry-hook-signature'] +expected_digest = request.headers.get('sentry-hook-signature') # returns None if header is missing body = json.dumps(request.body) digest = hmac.new( @@ -74,8 +74,10 @@ digest = hmac.new( digestmod=hashlib.sha256, ).hexdigest() +if not expected_digest: # The signature is missing + raise UnauthorizedError -if digest != expected_digest: +if not hmac.compare_digest(digest, expected_digest): raise UnauthorizedError ```