[extensions-web/feature/custom-user-class: 1/2] settings: allow to configure CORS using environment variable
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web/feature/custom-user-class: 1/2] settings: allow to configure CORS using environment variable
- Date: Sun, 22 May 2022 08:23:37 +0000 (UTC)
commit 4a50df3b343eefa0165423c09de420134dc16976
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Sun May 22 12:15:54 2022 +0400
settings: allow to configure CORS using environment variable
sweettooth/settings.py | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/sweettooth/settings.py b/sweettooth/settings.py
index 6b9ef4a..aa5ecd1 100644
--- a/sweettooth/settings.py
+++ b/sweettooth/settings.py
@@ -67,6 +67,11 @@ MIDDLEWARE = (
'django.contrib.messages.middleware.MessageMiddleware',
)
+if 'EGO_CORS_ORIGINS' in os.environ:
+ MIDDLEWARE = ('corsheaders.middleware.CorsMiddleware',) + MIDDLEWARE
+ INSTALLED_APPS + INSTALLED_APPS + ('corsheaders',)
+ CORS_ORIGIN_WHITELIST = list(map(str.strip, os.environ['EGO_CORS_ORIGINS'].split(",")))
+
AUTHENTICATION_BACKENDS = ['sweettooth.auth.backends.LoginEmailAuthentication']
SECURE_BROWSER_XSS_FILTER = True
@@ -182,19 +187,11 @@ if os.getenv('EGO_EMAIL_URL'):
NO_SECURE_SETTINGS = True if os.getenv('EGO_NO_SECURE_SETTINGS') else False
NO_STATICFILES_SETTINGS = False
-APPEND_INSTALLED_APPS = PREPEND_MIDDLEWARE = ()
-
try:
from local_settings import *
except ImportError:
pass
-if APPEND_INSTALLED_APPS:
- INSTALLED_APPS += APPEND_INSTALLED_APPS
-
-if PREPEND_MIDDLEWARE:
- MIDDLEWARE = PREPEND_MIDDLEWARE + MIDDLEWARE
-
# Enable secure settings in case DEBUG is disabled and NO_SECURE_SETTINGS is not set to True
if not DEBUG and not NO_SECURE_SETTINGS:
CSRF_COOKIE_SECURE = True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]