Repository navigation
fix(parser): keep the client certificate in APIGatewayProxyEventV2Model - #8851
Open
Manishram-ai wants to merge 1 commit into
Open
Manishram-ai wants to merge 1 commit into
Manishram-ai wants to merge 1 commit into
Conversation
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number:
closes #8848
Summary
Changes
RequestContextV2has an optionalauthenticationfield now, with the client certificate API Gateway sends when mutual TLS is on (PEM, subject DN, issuer DN, serial number and validity dates).ApiGatewayAuthorizerRequestV2gets it too, since it uses the same request context.RequestContextV2Authentication,RequestContextV2ClientCertandRequestContextV2ClientCertValiditymodels are exported fromparser.modelslike the otherRequestContextV2models. They're defined inapigwv2.pyinstead of reusingApiGatewayUserCert, because importingapigw.pywould load the REST models whenever a v2 model is used, andtest_model_imports.pychecks that it doesn't.User experience
Today the certificate is dropped during parsing, so a handler or an HTTP API Lambda authorizer that wants to check the client's subject DN has to go back to the raw event. With this change
parsed.requestContext.authentication.clientCert.subjectDNreturnswww.example.comfor the repo'sapiGatewayProxyV2Event.json. Events without mutual TLS parse the same as before, withauthenticationset toNone, including Lambda function URL events that send"authentication": null.model_dump()on the request context now includes anauthenticationkey.Verification
developwith'RequestContextV2' object has no attribute 'authentication', and pass with this change.tests/unit/parserandtests/functional/parser: 275 passed on Python 3.10, 3.12 and 3.14.ruff check,ruff format --checkandmypyare clean, andtests/performancepasses.tests/events, and it matches the certificate fields the REST model already parses.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.