Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 Python S3Boto 403 Forbidden When Signature Has '+' sign

I am using Django and S3Boto and whenever a signature has a '+' sign in it, I get a 403 Forbidden. If there is no '+' sign in the signature, I get the resource just fine. What could be wrong here?

UPDATE:

The repo is at : https://github.com/boto/boto

the files concerned are:

boto/utils.py
boto/s3/connection.py

NOTE: I am quite new to Python. I tried modifying the code but I still can't get the encoding done properly.

like image 893
yretuta Avatar asked Aug 17 '12 13:08

yretuta


1 Answers

I'm a little short on time (as it's 1:30am) so unfortunately I do not have a code sample for you yet, but I believe this is because the value + in a URL should be encoded. So from github, your url of...

https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=+tahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA

should really be

https://s3.amazonaws.com/dragonflysco/static/js/plugins/blockui.js?Signature=%2BtahbTacs5Vkzt5jQ+hZULzGPhE=&Expires=1345019173&AWSAccessKeyId=AKIAJNCPYIZVZXKOPCHA

(Note: I replaced the + with %2B)

See http://www.w3schools.com/tags/ref_urlencode.asp

To fix the code, I would add an URLEncoding function where it builds the URL query string.

like image 102
Wulfram Avatar answered Sep 29 '22 20:09

Wulfram