diff --git a/eventbridge-webhooks/1-stripe/src/app.py b/eventbridge-webhooks/1-stripe/src/app.py index f88f2d062..17b09dc6d 100644 --- a/eventbridge-webhooks/1-stripe/src/app.py +++ b/eventbridge-webhooks/1-stripe/src/app.py @@ -6,7 +6,6 @@ import base64 import hmac import hashlib -from cgi import parse_header import boto3 import botocore import botocore.session @@ -200,7 +199,7 @@ def get_content_type(headers): if raw_content_type is None: return None - content_type, _ = parse_header(raw_content_type) + content_type = raw_content_type.split(';')[0].strip() return content_type diff --git a/eventbridge-webhooks/1-stripe/src/requirements.txt b/eventbridge-webhooks/1-stripe/src/requirements.txt index 1db657b6b..52762ff6c 100644 --- a/eventbridge-webhooks/1-stripe/src/requirements.txt +++ b/eventbridge-webhooks/1-stripe/src/requirements.txt @@ -1 +1,2 @@ -boto3 \ No newline at end of file +boto3 +aws-secretsmanager-caching diff --git a/eventbridge-webhooks/2-github/src/app.py b/eventbridge-webhooks/2-github/src/app.py index 2b23e6a3c..05d131b53 100644 --- a/eventbridge-webhooks/2-github/src/app.py +++ b/eventbridge-webhooks/2-github/src/app.py @@ -6,7 +6,6 @@ import base64 import hmac import hashlib -from cgi import parse_header import boto3 import botocore import botocore.session @@ -160,7 +159,7 @@ def get_content_type(headers): if raw_content_type is None: return None - content_type, _ = parse_header(raw_content_type) + content_type = raw_content_type.split(';')[0].strip() return content_type diff --git a/eventbridge-webhooks/2-github/src/requirements.txt b/eventbridge-webhooks/2-github/src/requirements.txt index 1db657b6b..52762ff6c 100644 --- a/eventbridge-webhooks/2-github/src/requirements.txt +++ b/eventbridge-webhooks/2-github/src/requirements.txt @@ -1 +1,2 @@ -boto3 \ No newline at end of file +boto3 +aws-secretsmanager-caching diff --git a/eventbridge-webhooks/3-twilio/src/app.py b/eventbridge-webhooks/3-twilio/src/app.py index ccb97e385..681c0547b 100644 --- a/eventbridge-webhooks/3-twilio/src/app.py +++ b/eventbridge-webhooks/3-twilio/src/app.py @@ -7,7 +7,6 @@ import hmac import hashlib from functools import reduce -from cgi import parse_header import boto3 import botocore import botocore.session @@ -18,7 +17,7 @@ cache_config = SecretCacheConfig() cache = SecretCache(config=cache_config, client=client) -github_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN') +twilio_webhook_secret_arn = os.environ.get('TWILIO_WEBHOOK_SECRET_ARN') event_bus_name = os.environ.get('EVENT_BUS_NAME', 'default') event_bridge_client = boto3.client('events') @@ -114,7 +113,7 @@ def contains_valid_signature(payload_object, url, event_signature): """Check for the payload signature Twilio documentation: https://www.twilio.com/docs/usage/webhooks/webhooks-security#validating-signatures-from-twilio """ - secret = cache.get_secret_string(github_webhook_secret_arn) + secret = cache.get_secret_string(twilio_webhook_secret_arn) payload_bytes = get_payload_bytes( url=url, payload_object=payload_object @@ -166,7 +165,7 @@ def get_content_type(headers): if raw_content_type is None: return None - content_type, _ = parse_header(raw_content_type) + content_type = raw_content_type.split(';')[0].strip() return content_type diff --git a/eventbridge-webhooks/3-twilio/src/requirements.txt b/eventbridge-webhooks/3-twilio/src/requirements.txt index 1db657b6b..52762ff6c 100644 --- a/eventbridge-webhooks/3-twilio/src/requirements.txt +++ b/eventbridge-webhooks/3-twilio/src/requirements.txt @@ -1 +1,2 @@ -boto3 \ No newline at end of file +boto3 +aws-secretsmanager-caching