コード例 #1
0
 def read_input_file(self, filename):
     storage = AzureStorage()
     with storage.open(filename) as input_file:
         return [dict(r) for r in csv.DictReader(
             input_file,
             restkey='__extra_columns__',
             restval='__missing_columns__')]
コード例 #2
0
ファイル: tasks.py プロジェクト: unicef/etools
 def read_input_file(self, filename):
     storage = AzureStorage()
     with storage.open(filename) as input_file:
         return [dict(r) for r in csv.DictReader(
             input_file,
             restkey='__extra_columns__',
             restval='__missing_columns__')]
コード例 #3
0
ファイル: tasks.py プロジェクト: adi130987/etools
def sync_users_remote():
    from storages.backends.azure_storage import AzureStorage
    storage = AzureStorage()
    user_sync = UserMapper()
    with storage.open('saml/etools.dat') as csvfile:
        reader = csv.DictReader(csvfile, delimiter=bytes('|'))
        for row in reader:
            uni_row = {
                str(key, 'latin-1'): str(value, 'latin-1') for key, value in row.items()}
            user_sync.create_or_update_user(uni_row)
コード例 #4
0
ファイル: production.py プロジェクト: fafcrumb/etools
        'public': {
            'main': {
                'ENGINE': 'storages.backends.azure_storage.AzureStorage',
                'UPLOAD_TO': 'partners.utils.by_pca',
            },
        },
        'private': {
            'main': {
                'ENGINE': 'storages.backends.azure_storage.AzureStorage',
                'UPLOAD_TO': 'partners.utils.by_pca',
            },
        },
    }

    from storages.backends.azure_storage import AzureStorage
    storage = AzureStorage()
    with storage.open('saml/certs/saml.key') as key, \
            storage.open('saml/certs/sp.crt') as crt, \
            storage.open('saml/federationmetadata.xml') as meta:
        with open('EquiTrack/saml/certs/saml.key', 'w+') as new_key, \
                open('EquiTrack/saml/certs/sp.crt', 'w+') as new_crt, \
                open('EquiTrack/saml/federationmetadata.xml', 'w+') as new_meta:
            new_key.write(key.read())
            new_crt.write(crt.read())
            new_meta.write(meta.read())


SECRET_KEY = os.environ.get("SECRET_KEY", SECRET_KEY)
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
コード例 #5
0
 def _save(self, name, content):
     Arches3dCustomStorageManifestStaticFilesStorage()._save(name, content)
     AzureStorage()._save(name, content)
     return name
コード例 #6
0
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

# django-storages: https://django-storages.readthedocs.io/en/latest/backends/azure.html
AZURE_ACCOUNT_NAME = get_from_secrets_or_env('AZURE_ACCOUNT_NAME')  # noqa: F405
AZURE_ACCOUNT_KEY = get_from_secrets_or_env('AZURE_ACCOUNT_KEY')  # noqa: F405
AZURE_CONTAINER = get_from_secrets_or_env('AZURE_CONTAINER')  # noqa: F405
AZURE_SSL = True
AZURE_AUTO_SIGN = True  # flag for automatically signing urls
AZURE_ACCESS_POLICY_EXPIRY = 10800  # length of time before signature expires in seconds
AZURE_ACCESS_POLICY_PERMISSION = 'r'  # read permission

if AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY and AZURE_CONTAINER:
    DEFAULT_FILE_STORAGE = 'etools.libraries.azure_storage_backend.EToolsAzureStorage'
    from storages.backends.azure_storage import AzureStorage
    storage = AzureStorage()
    with storage.open('keys/jwt/key.pem') as jwt_key, \
            storage.open('keys/jwt/certificate.pem') as jwt_cert:

        with open(os.path.join(CONFIG_ROOT, 'keys/jwt/key.pem'), 'wb+') as new_jwt_key, \
                open(os.path.join(CONFIG_ROOT, 'keys/jwt/certificate.pem'), 'wb+') as new_jwt_cert:

            new_jwt_key.write(jwt_key.read())
            new_jwt_cert.write(jwt_cert.read())

# production overrides for django-rest-framework-jwt
if not get_from_secrets_or_env('DISABLE_JWT_LOGIN', False):
    private_key_bytes = open(join(CONFIG_ROOT, 'keys/jwt/key.pem'), 'rb').read()  # noqa: F405
    public_key_bytes = open(join(CONFIG_ROOT, 'keys/jwt/certificate.pem'), 'rb').read()  # noqa: F405

    JWT_PRIVATE_KEY = serialization.load_pem_private_key(private_key_bytes, password=None,
コード例 #7
0
ファイル: production.py プロジェクト: nixworks/etools
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

# django-storages: https://django-storages.readthedocs.io/en/latest/backends/azure.html
AZURE_ACCOUNT_NAME = os.environ.get('AZURE_ACCOUNT_NAME')  # noqa: F405
AZURE_ACCOUNT_KEY = os.environ.get('AZURE_ACCOUNT_KEY')  # noqa: F405
AZURE_CONTAINER = os.environ.get('AZURE_CONTAINER')  # noqa: F405
AZURE_SSL = True
AZURE_AUTO_SIGN = True  # flag for automatically signing urls
AZURE_ACCESS_POLICY_EXPIRY = 10800  # length of time before signature expires in seconds
AZURE_ACCESS_POLICY_PERMISSION = 'r'  # read permission

if AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY and AZURE_CONTAINER:
    DEFAULT_FILE_STORAGE = 'storages.backends.azure_storage.AzureStorage'
    from storages.backends.azure_storage import AzureStorage
    storage = AzureStorage()
    with storage.open('saml/certs/saml.key') as key, \
            storage.open('saml/certs/sp.crt') as crt, \
            storage.open('saml/federationmetadata.xml') as meta, \
            storage.open('keys/jwt/key.pem') as jwt_key, \
            storage.open('keys/jwt/certificate.pem') as jwt_cert:

        with open('EquiTrack/saml/certs/saml.key', 'w+') as new_key, \
                open('EquiTrack/saml/certs/sp.crt', 'w+') as new_crt, \
                open('EquiTrack/keys/jwt/key.pem', 'w+') as new_jwt_key, \
                open('EquiTrack/keys/jwt/certificate.pem', 'w+') as new_jwt_cert, \
                open('EquiTrack/saml/federationmetadata.xml', 'w+') as new_meta:

            new_key.write(key.read())
            new_crt.write(crt.read())
            new_meta.write(meta.read())
コード例 #8
0
def select_storage():
    return FileSystemStorage() if settings.DEBUG else AzureStorage()
コード例 #9
0
ファイル: storages.py プロジェクト: AngellusMortis/boundlexx
def select_storage(name):
    if "AzureStorage" in settings.DEFAULT_FILE_STORAGE:
        return AzureStorage(
            azure_container=f"{settings.AZURE_CONTAINER_PREFIX}{name}")
    return FileSystemStorage()