|
117 | 117 | "django.middleware.security.SecurityMiddleware",
|
118 | 118 | "corsheaders.middleware.CorsMiddleware",
|
119 | 119 | "csp.middleware.CSPMiddleware",
|
| 120 | + "whitenoise.middleware.WhiteNoiseMiddleware", |
120 | 121 | "django.contrib.sessions.middleware.SessionMiddleware",
|
121 | 122 | "django.middleware.locale.LocaleMiddleware",
|
122 | 123 | "django.middleware.common.CommonMiddleware",
|
|
127 | 128 | "django.middleware.clickjacking.XFrameOptionsMiddleware",
|
128 | 129 | ]
|
129 | 130 |
|
| 131 | +# CSP MIDDLEWARE CONFIGURATION |
| 132 | +# ------------------------------------------------------------------------------ |
| 133 | +CSP_SCRIPT_SRC = [ |
| 134 | + "'self'", |
| 135 | + "https://stackpath.bootstrapcdn.com", |
| 136 | + "https://cdn.jsdelivr.net", |
| 137 | + "https://code.jquery.com", |
| 138 | + "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js", |
| 139 | + "https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js" |
| 140 | +] |
| 141 | +CSP_STYLE_SRC = [ |
| 142 | + "'self'", |
| 143 | + "https://stackpath.bootstrapcdn.com" |
| 144 | +] |
| 145 | +CSP_IMG_SRC = [ |
| 146 | + "'self'", |
| 147 | +] |
| 148 | + |
| 149 | + |
130 | 150 | # STATIC
|
131 | 151 | # ------------------------------------------------------------------------------
|
132 | 152 | # https://docs.djangoproject.com/en/dev/ref/settings/#static-root
|
|
154 | 174 | TEMPLATES = [
|
155 | 175 | {
|
156 | 176 | # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
|
157 |
| - "BACKEND": "django.template.backends.django.DjangoTemplates", |
| 177 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
158 | 178 | # https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs
|
159 |
| - "DIRS": [str(APPS_DIR / "templates")], |
160 |
| - "OPTIONS": { |
161 |
| - # https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders |
162 |
| - # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types |
163 |
| - "loaders": [ |
164 |
| - "django.template.loaders.filesystem.Loader", |
165 |
| - "django.template.loaders.app_directories.Loader", |
166 |
| - ], |
167 |
| - # https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors |
168 |
| - "context_processors": [ |
| 179 | + 'DIRS': [(str(APPS_DIR / "templates"))], |
| 180 | + 'OPTIONS': { |
| 181 | + 'context_processors': [ |
169 | 182 | "django.template.context_processors.debug",
|
170 | 183 | "django.template.context_processors.request",
|
171 | 184 | "django.contrib.auth.context_processors.auth",
|
|
175 | 188 | "django.template.context_processors.tz",
|
176 | 189 | "django.contrib.messages.context_processors.messages",
|
177 | 190 | "tmh_registry.utils.context_processors.settings_context",
|
| 191 | + 'csp.context_processors.nonce' |
| 192 | + ], |
| 193 | + # https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders |
| 194 | + # https://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types |
| 195 | + 'loaders': [ |
| 196 | + 'django.template.loaders.filesystem.Loader', |
| 197 | + 'django.template.loaders.app_directories.Loader' |
178 | 198 | ],
|
179 | 199 | },
|
180 |
| - } |
| 200 | + }, |
181 | 201 | ]
|
182 | 202 |
|
183 |
| -# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer |
184 |
| -FORM_RENDERER = "django.forms.renderers.TemplatesSetting" |
185 |
| - |
186 |
| -# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs |
187 |
| -CRISPY_TEMPLATE_PACK = "bootstrap4" |
188 |
| - |
189 |
| -# FIXTURES |
190 |
| -# ------------------------------------------------------------------------------ |
191 |
| -# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs |
192 |
| -FIXTURE_DIRS = (str(APPS_DIR / "fixtures"),) |
193 |
| - |
194 | 203 | # SECURITY
|
195 | 204 | # ------------------------------------------------------------------------------
|
196 | 205 | # https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
|
|
0 commit comments