diff --git a/docs/settings.rst b/docs/settings.rst index f3df0841..a76e5379 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -282,6 +282,18 @@ Links are generated as presigned urls for security EXPLORER_S3_LINK_EXPIRATION = 3600 +S3 signature version +******************** + +The signature version when signing requests. +As of ``boto3`` version 1.13.21 the default signature version used for generating presigned urls is still ``v2``. +To be able to access your s3 objects in all regions through presigned urls, explicitly set this to ``s3v4``. + +.. code-block:: python + + EXPLORER_S3_SIGNATURE_VERSION = 's3v4' + + From email ********** diff --git a/explorer/app_settings.py b/explorer/app_settings.py index 7d73d17c..06a4d00d 100644 --- a/explorer/app_settings.py +++ b/explorer/app_settings.py @@ -133,6 +133,7 @@ S3_REGION = getattr(settings, "EXPLORER_S3_REGION", "us-east-1") S3_ENDPOINT_URL = getattr(settings, "EXPLORER_S3_ENDPOINT_URL", None) S3_DESTINATION = getattr(settings, "EXPLORER_S3_DESTINATION", '') +S3_SIGNATURE_VERSION = getattr(settings, "EXPLORER_S3_SIGNATURE_VERSION", 'v2') UNSAFE_RENDERING = getattr(settings, "EXPLORER_UNSAFE_RENDERING", False) diff --git a/explorer/utils.py b/explorer/utils.py index 8f6b503e..6cb4369a 100644 --- a/explorer/utils.py +++ b/explorer/utils.py @@ -193,10 +193,14 @@ def get_valid_connection(alias=None): def get_s3_bucket(): import boto3 + from botocore.client import Config kwargs = { 'aws_access_key_id': app_settings.S3_ACCESS_KEY, 'aws_secret_access_key': app_settings.S3_SECRET_KEY, - 'region_name': app_settings.S3_REGION + 'region_name': app_settings.S3_REGION, + 'config': Config( + signature_version=app_settings.S3_SIGNATURE_VERSION + ) } if app_settings.S3_ENDPOINT_URL: kwargs['endpoint_url'] = app_settings.S3_ENDPOINT_URL