-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
implement S3 v3 pre-signed handler #8918
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
Conversation
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.
LGTM! modifying the headers this way seems fine (we allowed for request header mutability for exactly these use cases). the impact on the handler chain is minimal since we're only executing this for specific services, which is good.
the encapsulation in the handler class is 👌
great set of changes overall! 🥇
class ParsePreSignedUrlRequest(Handler): | ||
def __init__(self): | ||
self.pre_signed_handlers: dict[str, Handler] = { | ||
"s3": S3PreSignedURLRequestHandler(), | ||
} |
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.
nice 👍 maybe at some point in the future we can consolidate this with ServiceResponseHandlers
3ed03e0
to
153493c
Compare
626bc96
to
555135b
Compare
555135b
to
2c1a505
Compare
Motivation
Move the s3 pre-signed handler earlier in the handler chain, so that we can modify the request in the
RequestContext
before actually parsing it: this allows us to fully use the ASF parser.When pre-signing a request, the S3 client will move some of the request parameters into the query string, when those parameters would be in the headers. Now, the pre-signed handler will add back some headers that we know should be in there, and the parser will properly pick it up.
Changes
Create a general pre-signed handler in the handler chain, which will be able to manage more kind of pre-signed URL than S3. Only S3 is implemented now. Some logic had to be changed in the handler, because we were using the previously parsed
Bucket
from the request. We now need to parse it ourselves following the same logic as the RequestParser (especially a weird case where we had the sanitized path, and we needed the raw one).