implement S3 ASF pre-signed POST support #6980
Merged
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.
This PR implements S3 pre-signed POST support
Currently, the provider does not implement signature validation, but it is not a lot of work to implement, as only the policy is signed (a JSON string encoded in base64). It can be done in a follow up PR.
To implement support for this operation, we needed to create an operation not defined in the specs, as the clients (like
Boto
) would never call directly to this URL. But it is implement server side, and documented. See https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.htmlAlso, I had to make a small change to the serializer, but I'm not sure it should be generalised. I think 3XX status code are not supposed to return a body. So I skipped serializing the body in case the status code was >= 300 and < 400.
It also came to light that the botocore parser does not like 3XX responses from moto, as it tries to parse them as exception. I need to add a special
try...except
clause to catch the exception and act in consequence.It also implements small tests fixes for pre-signed URL in general, and wrong logic in skipping them/checking conditions based on Legacy/ASF.