Reputation: 7044
I'm giving to a client a presigned url for put_object method:
Server:
s3_client = boto3.client('s3')
res = s3_client.generate_presigned_url('put_object', Params = {'Bucket': 'my-bucket', 'Key': 'filepath/inside-bucket/filename.json'}, ExpiresIn = 3600)
Now, if the client sends the presigned url back to the server, how can the server validate the url is valid (signature)?
Ideally I would like to call an s3 service function to do that.
As I see there is no way to generate presigned url for multiple methods (head_object + put_object)
My use case is:
I know I can use lambda s3 trigger, but that will make the process async, more difficult to know when the object was handling we completed.
Upvotes: 2
Views: 4077
Reputation: 270154
The pre-signed URL simply includes a hashed signature of the parameters included with the request, signed with the Secret Key.
If you have the Secret Key of the Access Key shown in the request, you can create the hashed signature yourself and verify that the signature is correct (if the hashes match).
There is code available in: StackOverflow: AWS S3 presigned urls with boto3 - Signature mismatch
Upvotes: 2