S3 Hosting / query string Authentication with additional parameters

I have setup a Django project with S3 as a static file host.

settings.py

 AWS_STORAGE_BUCKET_NAME = 'project-1' conn = boto.connect_s3() STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage' S3_URL = 'http://project-1.s3.amazonaws.com/' STATIC_URL = S3_URL 

And then I make links to static files in my templates using the template tag, for example:

 <script src="{% static 'js/jquery.payment.js' %}"></script> 

This displays correctly inside the browser, but the URL has 3 other parameters, Signature , Expires and AWSAccessKeyId . The last two do not affect the file, but access to the file with the displayed Signature value results in an InvalidAccessKeyId error, and the message "The AWS passkey identifier that you specified does not exist in our records."

By manually overriding the Signature parameter, I can access the file in order. Remove all three parameters in order. Removing one of the last two parameters results in an error: "Signature, Expires, and AWSAccessKeyId parameters are required for authentication in query strings."

Amazon S3 documentation shows that query string authentication is used to access files that typically require authentication, and that Expires not what I thought was about caching. Since it seems that these files do not require any authentication (i.e., I can access them when there are no URL parameters), I need help:

  • creating staticfiles / boto does not force these parameters on my urls
  • creating staticfiles / boto to get a valid Signature value
+4
source share
1 answer

Set AWS_QUERYSTRING_AUTH = False .

+9
source

Source: https://habr.com/ru/post/1490014/


All Articles