Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make jwtConfiguration fields lower case #2737

Merged
merged 10 commits into from
Dec 16, 2022
15 changes: 13 additions & 2 deletions samtranslator/model/apigatewayv2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union

from samtranslator.model import PropertyType, Resource
from samtranslator.model.types import is_type, one_of, is_str, list_of
Expand Down Expand Up @@ -69,6 +69,11 @@ class ApiGatewayV2ApiMapping(Resource):
}


# https://docs.aws.amazon.com/apigatewayv2/latest/api-reference/apis-apiid-authorizers-authorizerid.html#apis-apiid-authorizers-authorizerid-model-jwtconfiguration
# Change to TypedDict when we don't have to support Python 3.7
JwtConfiguration = Dict[str, Union[str, List[str]]]


class ApiGatewayV2Authorizer(object):
def __init__( # type: ignore[no-untyped-def]
self,
Expand All @@ -90,7 +95,7 @@ def __init__( # type: ignore[no-untyped-def]
self.api_logical_id = api_logical_id
self.name = name
self.authorization_scopes = authorization_scopes
self.jwt_configuration = jwt_configuration
self.jwt_configuration: Optional[JwtConfiguration] = self._get_jwt_configuration(jwt_configuration)
self.id_source = id_source
self.function_arn = function_arn
self.function_invoke_role = function_invoke_role
Expand Down Expand Up @@ -299,3 +304,9 @@ def _get_reauthorize_every(self): # type: ignore[no-untyped-def]
return None

return self.identity.get("ReauthorizeEvery")

@staticmethod
def _get_jwt_configuration(props: Optional[Dict[str, Union[str, List[str]]]]) -> Optional[JwtConfiguration]:
if not props:
return None
return {k.lower(): v for k, v in props.items()}
ssenchenko marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions tests/translator/input/http_api_multiple_authorizers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Resources:
- scope
IdentitySource: $request.header.Authorization
JwtConfiguration:
audience:
Audience:
hoffa marked this conversation as resolved.
Show resolved Hide resolved
- audience1
- audience2
issuer: https://www.example.com/v1/connect/oidc
Issuer: https://www.example.com/v1/connect/oidc
DefaultAuthorizer: LambdaAuth
EnableIamAuthorizer: true