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
fix: Raise exception if provided Auth.Authorizers.Identity isn't a dict #2273
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2273 +/- ##
===========================================
+ Coverage 93.58% 94.39% +0.81%
===========================================
Files 90 97 +7
Lines 6124 7086 +962
Branches 1260 1434 +174
===========================================
+ Hits 5731 6689 +958
+ Misses 183 181 -2
- Partials 210 216 +6
Continue to review full report at Codecov.
|
samtranslator/model/apigateway.py
Outdated
try: | ||
if not self.identity or not self.identity.get("Header"): | ||
return "Authorization" | ||
except AttributeError: | ||
raise InvalidResourceException( | ||
self.api_logical_id, | ||
"Auth.Authorizers.<Authorizer>.Identity must be a dict (LambdaTokenAuthorizationIdentity " | ||
"or LambdaRequestAuthorizationIdentity).", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of try/except
block, shouldn't we check if the property is an expected type (dict in this case)?
Issue #, if available:
Description of changes:
Description of how you validated changes:
Checklist:
make pr
passesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam init
through https://github.com/awslabs/aws-sam-cli-app-templates/By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.