Skip to content

Commit 75034e7

Browse files
authored
Update app.py
1 parent bb9d67f commit 75034e7

File tree

1 file changed

+3
-4
lines changed
  • eventbridge-webhooks/3-twilio/src

1 file changed

+3
-4
lines changed

eventbridge-webhooks/3-twilio/src/app.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import hmac
88
import hashlib
99
from functools import reduce
10-
from cgi import parse_header
1110
import boto3
1211
import botocore
1312
import botocore.session
@@ -18,7 +17,7 @@
1817
cache_config = SecretCacheConfig()
1918
cache = SecretCache(config=cache_config, client=client)
2019

21-
github_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN')
20+
twilio_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN')
2221
event_bus_name = os.environ.get('EVENT_BUS_NAME', 'default')
2322

2423
event_bridge_client = boto3.client('events')
@@ -114,7 +113,7 @@ def contains_valid_signature(payload_object, url, event_signature):
114113
"""Check for the payload signature
115114
Twilio documentation: https://www.twilio.com/docs/usage/webhooks/webhooks-security#validating-signatures-from-twilio
116115
"""
117-
secret = cache.get_secret_string(github_webhook_secret_arn)
116+
secret = cache.get_secret_string(twilio_webhook_secret_arn)
118117
payload_bytes = get_payload_bytes(
119118
url=url,
120119
payload_object=payload_object
@@ -166,7 +165,7 @@ def get_content_type(headers):
166165

167166
if raw_content_type is None:
168167
return None
169-
content_type, _ = parse_header(raw_content_type)
168+
content_type = raw_content_type.split(';')[0].strip()
170169
return content_type
171170

172171

0 commit comments

Comments
 (0)