boto / boto3

AWS SDK for Python
https://aws.amazon.com/sdk-for-python/
Apache License 2.0
8.81k stars 1.84k forks source link

Generate presigned URL not working with put_object #4146

Closed ngocbuildxuan closed 1 week ago

ngocbuildxuan commented 1 month ago

Describe the bug

I create two s3_client instances: 1 by implicit, 1 with by env. The first one generate URL: X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQVIT***/20240524/ap-northeast-1/s3/aws4_request&X-Amz-Date=20240524T105432Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=1b675af482e124ebd9d8bca12162e8de6a485290c1f6340663cf3471b090c953

And other one: AWSAccessKeyId=AKIAQVIT***&Signature=b8syQZopTatE44pixkGnTTqoqgI=&Expires=1716551682

My two instance can generate well with get_object, but with put_object, the second can not use SignatureDoesNotMatch

I see that there are some differences URL query string, is there made my error ?

Expected Behavior

Generate url with put_object work as normal as get_object

Current Behavior

The instance create by implicit way can not generate URL for put_object. The URL return 403 error SignatureDoesNotMatch

Reproduction Steps

s3_client.generate_presigned_url(
                    'put_object',
                    Params={
                        'Bucket': bucket, 
                        'Key': object_key
                    },
                    ExpiresIn=3600,  # URL expires in 1 hour
                    HttpMethod='PUT'
                )

Possible Solution

No response

Additional Information/Context

No response

SDK version used

boto3==1.17.36

Environment details (OS name and version, etc.)

Linux

tim-finnigan commented 3 weeks ago

Hi @ngocbuildxuan thanks for reaching out. Version 1.17.36 is extremely old. The latest version is 1.34.119 per the CHANGELOG. Please try updating your version of the SDK for access to the latest features and fixes. If still seeing an issue, please share debug logs (with sensitive info redacted) by adding boto3.set_stream_logger('') to your script.

github-actions[bot] commented 1 week ago

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.