diff --git a/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py b/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py index c73eb33b9fe..6d05984128e 100644 --- a/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py +++ b/aws_lambda_powertools/utilities/data_classes/api_gateway_authorizer_event.py @@ -437,7 +437,7 @@ class APIGatewayAuthorizerResponse: - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-lambda-authorizer-output.html """ - path_regex = r"^[/.a-zA-Z0-9-_\*]+$" + path_regex = r"^[/.a-zA-Z0-9\-_\*\{\}\+]+$" """The regular expression used to validate resource paths for the policy""" def __init__( diff --git a/tests/unit/data_classes/required_dependencies/test_api_gateway_authorizer.py b/tests/unit/data_classes/required_dependencies/test_api_gateway_authorizer.py index 1fad5176672..c26c1a417e7 100644 --- a/tests/unit/data_classes/required_dependencies/test_api_gateway_authorizer.py +++ b/tests/unit/data_classes/required_dependencies/test_api_gateway_authorizer.py @@ -200,6 +200,40 @@ def test_authorizer_response_allow_route_with_underscore(builder: APIGatewayAuth } +def test_authorizer_response_allow_route_with_proxy_plus(builder: APIGatewayAuthorizerResponse): + builder.allow_route(http_method="GET", resource="/{proxy+}") + assert builder.asdict() == { + "principalId": "foo", + "policyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "execute-api:Invoke", + "Effect": "Allow", + "Resource": ["arn:aws:execute-api:us-west-1:123456789:fantom/dev/GET/{proxy+}"], + }, + ], + }, + } + + +def test_authorizer_response_allow_route_with_path_parameter(builder: APIGatewayAuthorizerResponse): + builder.allow_route(http_method="GET", resource="/users/{user_id}") + assert builder.asdict() == { + "principalId": "foo", + "policyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "execute-api:Invoke", + "Effect": "Allow", + "Resource": ["arn:aws:execute-api:us-west-1:123456789:fantom/dev/GET/users/{user_id}"], + }, + ], + }, + } + + def test_parse_api_gateway_arn_with_resource(): mock_event = { "type": "TOKEN",