-
Notifications
You must be signed in to change notification settings - Fork 427
Bug: Global apigateway swagger security config not overwritten by specific route configs with empty security #5893
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. |
Hi @victorperezpiqueras! Thanks for opening this issue because I see room for improvement in our documentation. Actually this is not a bug, we already support it. The OpenAPI v3 specification defines an optional security mechanism with Reference: https://spec.openapis.org/oas/v3.1.0.html#fixed-fields
Please let me know if this works for you. |
Ah, my bad I missed that doc. In that case, maybe the current field description could be extended with the complete description present in the OpenAPI specification:
I see the rest of the params have a simplified description too, so idk if its a standard or documentation choice. |
I would prefer to add it here: https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#security-schemes |
|
This is now released under 3.5.0 version! |
Expected Behaviour
I have defined an apigateway rest resolver with swagger enabled and a security scheme with oauth.
I have two endpoints, one protected, and one unprotected. I explicitly define the unprotected endpoint with security empty, so I would expect it to override the global config of swagger and be unprotected.
Current Behaviour
Currently, the unprotected security of the route is not overwritten. Instead, the global config seems to be applied over the specific one of the router. This only happens if the specific config is an empty list.
However, if the global config of security is an empty list or not defined at all, defining a specific security config in a route overwrites it.
With the current behaviour, if I want to keep all resources protected except one, I need to remove the global config of security, and put it in each route that i want protected.
Code snippet
Possible Solution
Either clarify the docs of the enable_swagger() or make the specific router security options override the global security even if the security is empty.
Steps to Reproduce
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.12
Packaging format used
Lambda Layers
Debugging logs
The text was updated successfully, but these errors were encountered: