From f1bfaf024267d7835422babe39aa1b1160440635 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Oct 2018 18:23:43 -0400 Subject: [PATCH 1/3] settings: split SECRET_FILE from SECRET_KEY --- etesync_server/settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etesync_server/settings.py b/etesync_server/settings.py index 521cb2f..9d5f119 100644 --- a/etesync_server/settings.py +++ b/etesync_server/settings.py @@ -23,7 +23,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: keep the secret key used in production secret! # See secret.py for how this is generated; uses a file 'secret.txt' in the root # directory -SECRET_KEY = get_secret_from_file(os.path.join(BASE_DIR, "secret.txt")) +SECRET_FILE = os.path.join(BASE_DIR, "secret.txt") +SECRET_KEY = get_secret_from_file(SECRET_FILE) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False From 872af56e2cd00669f13a80c74710bf7b9a19940e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Oct 2018 18:25:35 -0400 Subject: [PATCH 2/3] settings: support an external settings file Fixes #8 --- etesync_server/settings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etesync_server/settings.py b/etesync_server/settings.py index 9d5f119..d4b93d8 100644 --- a/etesync_server/settings.py +++ b/etesync_server/settings.py @@ -136,3 +136,9 @@ JOURNAL_API_PERMISSIONS = ( # Cors CORS_ORIGIN_ALLOW_ALL = True + +# Make an `etesync_site_settings` module available to override settings. +try: + from etesync_site_settings import * +except ImportError: + pass From e02fa53c34200de59288a16ed00fa0621a007578 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Oct 2018 18:26:13 -0400 Subject: [PATCH 3/3] settings: defer SECRET_KEY until after site settings This allows overriding just `SECRET_FILE` for a custom secret path. --- etesync_server/settings.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etesync_server/settings.py b/etesync_server/settings.py index d4b93d8..9556167 100644 --- a/etesync_server/settings.py +++ b/etesync_server/settings.py @@ -24,7 +24,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # See secret.py for how this is generated; uses a file 'secret.txt' in the root # directory SECRET_FILE = os.path.join(BASE_DIR, "secret.txt") -SECRET_KEY = get_secret_from_file(SECRET_FILE) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False @@ -142,3 +141,6 @@ try: from etesync_site_settings import * except ImportError: pass + +if 'SECRET_KEY' not in locals(): + SECRET_KEY = get_secret_from_file(SECRET_FILE)