예제 #1
0
    def process_request(self, request):
        whitelisted_views = ('two_factor:login', 'two_factor:setup',
                             'two_factor:qr', 'logout', 'javascript-catalog')
        if any([reverse(v) in request.path for v in whitelisted_views]):
            return None

        user = getattr(request, 'user', None)
        if user is None or user.is_anonymous:
            return None

        site_requires_2fa = EnvConfig().get("require_2fa", False) == 1

        if not user.is_verified() and (site_requires_2fa
                                       or user.require_2_fact_auth):
            return HttpResponseRedirect(reverse('two_factor:setup'))

        return None
예제 #2
0
# -*- coding: utf-8 -*-/MAIL
# Django settings for Bioplatforms Workflow project.

import os
from contextlib import suppress
from ccg_django_utils.conf import EnvConfig

env = EnvConfig()

VERSION = env.get("bpa_version", os.environ.get("GIT_TAG", "UNKNOWN_VERSION"))
BPA_VERSION = VERSION

SCRIPT_NAME = env.get("script_name", os.environ.get("HTTP_SCRIPT_NAME", ""))
FORCE_SCRIPT_NAME = env.get("force_script_name", "") or SCRIPT_NAME or None

# This should be the path under the webapp is installed on the server ex. /bpa/otu on staging
# TODO I think this is always SCRIPT_NAME if not get separately from enviroment
BASE_URL = SCRIPT_NAME

WEBAPP_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# a directory that will be writable by the webserver, for storing various files...
WRITABLE_DIRECTORY = env.get("writable_directory", "/tmp")

SECRET_KEY = env.get("secret_key", "change-it")

# Default SSL on and forced, turn off if necessary
PRODUCTION = env.get("production", False)
SSL_ENABLED = PRODUCTION
SSL_FORCE = PRODUCTION