django_settings.py 5.31 KB
Newer Older
1 2 3 4 5 6 7

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# SECURITY WARNING: don't run with debug turned on in production!
Lukas Burgey's avatar
Lukas Burgey committed
8
DEBUG = False
9

10
DEBUG_AUTH = False
Lukas Burgey's avatar
Lukas Burgey committed
11
DEBUG_PUBLISHING = False
Lukas Burgey's avatar
Lukas Burgey committed
12
DEBUG_CREDENTIALS = False
13

14
ALLOWED_HOSTS = [
Lukas Burgey's avatar
Lukas Burgey committed
15
    '$domain',
16 17 18 19 20 21 22 23 24
]

AUTH_USER_MODEL = 'backend.User'

# cookie settings
SESSION_COOKIE_AGE = 3600
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = False

Lukas Burgey's avatar
Lukas Burgey committed
25 26 27 28
WSGI_APPLICATION = 'feudal.wsgi.application'

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

29 30
CSRF_HEADER_NAME = 'HTTP_X_CSRFTOKEN'

Lukas Burgey's avatar
Lukas Burgey committed
31 32
CORS_ORIGIN_ALLOW_ALL = True

33 34 35 36
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
Lukas Burgey's avatar
Lukas Burgey committed
37
with open('$secret') as f:
38 39 40 41 42 43
    SECRET_KEY = f.read().strip()

# Application definition
ROOT_URLCONF = 'feudal.urls'

STATIC_URL = '/backend/static/'
Lukas Burgey's avatar
Lukas Burgey committed
44
STATIC_ROOT = '$static'
45 46 47 48

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
Lukas Burgey's avatar
Lukas Burgey committed
49
    'polymorphic',
50 51 52 53 54 55 56 57
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'feudal.backend',
    'corsheaders',
    'django_mysql',
Lukas Burgey's avatar
Lukas Burgey committed
58
    'django_nose',
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
Lukas Burgey's avatar
Lukas Burgey committed
92
            'read_default_file': os.path.expanduser('$mysql'),
93 94 95 96 97 98 99 100 101 102 103
            'init_command': "SET innodb_strict_mode=1; SET sql_mode='STRICT_TRANS_TABLES';",
            'charset': 'utf8mb4'
        },
        'TEST': {
            'NAME': 'scc-hdfmysql0001_portal_dev_test',
        }
    }
}

# AUTHENTICATION AND AUTHORIZATION
AUTHENTICATION_BACKENDS = [
Lukas Burgey's avatar
Lukas Burgey committed
104
    'feudal.backend.auth.v1.OIDCTokenAuthBackend',
105 106 107 108 109
    'django.contrib.auth.backends.ModelBackend',
]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
Lukas Burgey's avatar
Lukas Burgey committed
110
        'rest_framework.authentication.SessionAuthentication',
Lukas Burgey's avatar
Lukas Burgey committed
111
        'feudal.backend.auth.v1.OIDCTokenAuthHTTPBackend',
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    ],
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
}

# Password validation
AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
LANGUAGE_CODE = 'en-us'
136
TIME_ZONE = 'Europe/Berlin'
137 138 139 140 141
USE_I18N = True
USE_L10N = True
USE_TZ = True

# LOGGING
Lukas Burgey's avatar
Lukas Burgey committed
142
LOGGING_ROOT = os.path.expanduser('$logs')
143 144 145 146 147 148 149
LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'standard': {
            'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        },
150 151 152
        'compact': {
            'format': '%(levelname)s - %(message)s',
        },
153 154 155 156 157 158 159 160 161 162 163 164 165
    },
    'handlers': {
        'django': {
            'class': 'logging.FileHandler',
            'filename': LOGGING_ROOT + '/django.log',
            'formatter': 'standard',
        },
        'debug': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': LOGGING_ROOT + '/debug.log',
            'formatter': 'standard',
        },
166 167 168 169 170 171
        'compact-debug': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': LOGGING_ROOT + '/compact-debug.log',
            'formatter': 'compact',
        },
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
        'info': {
            'level': 'INFO',
            'class': 'logging.FileHandler',
            'filename': LOGGING_ROOT + '/info.log',
            'formatter': 'standard',
        },
        'error': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': LOGGING_ROOT + '/error.log',
            'formatter': 'standard',
        },
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
        },
    },
    'loggers': {
        'feudal': {
191
            'handlers': ['debug', 'info', 'error', 'compact-debug'],
192 193 194
            'level': 'DEBUG',
        },
        'django': {
195
            'handlers': ['debug', 'info', 'error', 'compact-debug'],
196 197 198 199
            'level': 'INFO',
        },
    },
}