Issues

Issue #149 resolved

NoAuthHandlerFound at /admin/

manelclos
created an issue

This is caused when you want to access /admin/ and using S3BotoStorage in dango-storages 1.1.6. It won't pick up credentials from the environment because the code in _get_access_keys() is wrong. Here is a fix, put it in a file and use this class instead:

from storages.backends.s3boto import S3BotoStorage from django.conf import settings import os

ACCESS_KEY = getattr(settings, 'AWS_ACCESS_KEY_ID', None) SECRET_KEY = getattr(settings, 'AWS_SECRET_ACCESS_KEY', None)

class FixedS3BotoStorage(S3BotoStorage):

def _get_access_keys(self):
    """
    Gets the access keys to use when accessing S3. If none
    are provided to the class in the constructor or in the
    settings then get them from the environment variables.
    """
    access_key = ACCESS_KEY
    secret_key = SECRET_KEY

    if not access_key or not secret_key:
        access_key = os.environ.get('AWS_ACCESS_KEY_ID')
        secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')

    if access_key and secret_key:
        # Both were provided, so use them
        return access_key, secret_key

    return None, None

Comments (3)

  1. Log in to comment