Skip to content

Commit

Permalink
Better logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneier committed Aug 14, 2017
1 parent 404ae60 commit cda5f52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions storages/backends/s3boto.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class S3BotoStorage(Storage):

access_key = setting('AWS_S3_ACCESS_KEY_ID', setting('AWS_ACCESS_KEY_ID'))
secret_key = setting('AWS_S3_SECRET_ACCESS_KEY', setting('AWS_SECRET_ACCESS_KEY'))
security_token = self._lookup_env(self.security_token_names)
file_overwrite = setting('AWS_S3_FILE_OVERWRITE', True)
headers = setting('AWS_HEADERS', {})
bucket_name = setting('AWS_STORAGE_BUCKET_NAME')
Expand Down Expand Up @@ -238,10 +239,8 @@ def __init__(self, acl=None, bucket=None, **settings):
self._connection = None
self._loaded_meta = False

self.security_token = None
if not self.access_key and not self.secret_key:
self.access_key, self.secret_key = self._get_access_keys()
self.security_token = self._get_security_token()

@property
def connection(self):
Expand Down Expand Up @@ -305,10 +304,6 @@ def _get_access_keys(self):
secret_key = self.secret_key or self._lookup_env(self.secret_key_names)
return access_key, secret_key

def _get_security_token(self):
security_token = self._lookup_env(self.security_token_names)
return security_token

def _get_or_create_bucket(self, name):
"""
Retrieves a bucket if it exists, otherwise creates it.
Expand Down
7 changes: 1 addition & 6 deletions storages/backends/s3boto3.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class S3Boto3Storage(Storage):

access_key = setting('AWS_S3_ACCESS_KEY_ID', setting('AWS_ACCESS_KEY_ID'))
secret_key = setting('AWS_S3_SECRET_ACCESS_KEY', setting('AWS_SECRET_ACCESS_KEY'))
security_token = self._lookup_env(self.security_token_names)
file_overwrite = setting('AWS_S3_FILE_OVERWRITE', True)
object_parameters = setting('AWS_S3_OBJECT_PARAMETERS', {})
bucket_name = setting('AWS_STORAGE_BUCKET_NAME')
Expand Down Expand Up @@ -239,10 +240,8 @@ def __init__(self, acl=None, bucket=None, **settings):
self._bucket = None
self._connections = threading.local()

self.security_token = None
if not self.access_key and not self.secret_key:
self.access_key, self.secret_key = self._get_access_keys()
self.security_token = self._get_security_token()

if not self.config:
self.config = Config(s3={'addressing_style': self.addressing_style},
Expand Down Expand Up @@ -307,10 +306,6 @@ def _get_access_keys(self):
secret_key = self.secret_key or self._lookup_env(self.secret_key_names)
return access_key, secret_key

def _get_security_token(self):
security_token = self._lookup_env(self.security_token_names)
return security_token

def _get_or_create_bucket(self, name):
"""
Retrieves a bucket if it exists, otherwise creates it.
Expand Down

0 comments on commit cda5f52

Please sign in to comment.