Skip to content

Commit

Permalink
Allow setting signature version to S3 uploader (#537)
Browse files Browse the repository at this point in the history
* Allow setting signature version to S3

* Add missing docs
  • Loading branch information
lucas-giaco authored Dec 16, 2023
1 parent 692e4cc commit 51e4f0d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********

Expand Down
1 change: 1 addition & 0 deletions explorer/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion explorer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51e4f0d

Please sign in to comment.