How to configure AWS4 S3 Authorization in Django?

和自甴很熟 提交于 2020-01-16 13:12:06

问题


I configurred S3 bucket for Frankfurt region. Though my Django-based service is able to write files to the bucket, whenever it tried to read them there's InvalidRequest error telling to upgrate authorization mechanizm:

<Error>
  <Code>InvalidRequest</Code>
  <Message>
    The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
  </Message>
  <RequestId>17E9629D33BF1E24</RequestId>
  <HostId>
    ...
  </HostId>
</Error>

Is the cause for this error burried in my incorrect implementation of storage backend or is this caused by bucket not supporting older AWS3 method of authorization?

How to configure S3Boto3Storage in Django to use AWS4 authorization? I can't find any definitive documentation on this topic.


回答1:


Since you mentioned the S3Boto3Storage backend, I'm assuming you're using django-storages rather than writing your own implementation. There's a setting that lets you specify which signature version to use, AWS_S3_SIGNATURE_VERSION = 's3v4' you can find the full list of settings for S3 here https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings



来源:https://stackoverflow.com/questions/59543979/how-to-configure-aws4-s3-authorization-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!