-
Notifications
You must be signed in to change notification settings - Fork 423
Bug: APIGatewayHttpResolver
doesn't make custome attribute under requestContext.authorizer
available in the function
#3444
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
requestContext.authorizer
availableAPIGatewayHttpResolver
doesn't make custome attribute under requestContext.authorizer
available in the function
An example project might make it easier :) https://github.com/dennisseidel/aws-powertool-bug-example Thank you for your great work! |
ACK; seeing shortly (pulling my laptop at the airport gate) |
@dennisseidel ah that's not a bug (phew!). You'd have to use Here's the updated line that causes an error app.current_event.request_context.authorizer.get("tenantId")
# Instead of .<attribute> which would lead to an AttributeError
# app.current_event.request_context.authorizer.tenantId Does that make sense? That said, looking at the implementation we have an incorrect property API Reference |
this was so helpful, spot the issue in 10s, needed more time to confirm docs and test locally |
@heitorlessa Thank you for the quick support 🙏 Indeed I no bug but just me not using it right 🙈 |
|
reopening as @leandrodamascena is testing and we'll come back with a solution |
@dennisseidel we improved the experience thanks to you! Today's release will have a new from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools import Logger
app = APIGatewayRestResolver()
logger = Logger(level="INFO")
@app.get("/")
def initialize():
context: dict = app.current_event.request_context.authorizer.get_context()
logger.info(context.get("tenantId"))
def lambda_handler(event, context):
return app.resolve(event, context) |
|
This is now released under 2.29.0 version! |
Expected Behaviour
All paramters that are part of the input object unter authorizer are available in the function and accessible on the object.
Current Behaviour
APIGatewayHttpResolver doesn't pass in attribute from
requestContext.authorizer
. My understanding is that i can in the lambda authorizer can add ther custome attributes e.g. like tenantId but that doesn't get passed to the function. Currently the expected tenantId mis missing:Code snippet
requreiments.txt
template.yaml
initalize-event.json
The text was updated successfully, but these errors were encountered: