Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions openIMIS/openIMIS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
)


def get_secret(key, default):
value = os.getenv(key, default)
if value and os.path.isfile(value):
with open(value) as f:
return f.read().rstrip()
return value


def SITE_ROOT():
root = os.environ.get("SITE_ROOT", "")
if root == "":
Expand All @@ -119,7 +127,7 @@ def SITE_URL():
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get(
SECRET_KEY = get_secret(
"SECRET_KEY", "chv^^7i_v3-04!rzu&qe#+h*a=%h(ib#5w9n$!f2q7%2$qp=zz"
)

Expand Down Expand Up @@ -312,7 +320,7 @@ def SITE_URL():
"ENGINE": DB_ENGINE,
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"PASSWORD": get_secret("DB_PASSWORD", ""),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
"OPTIONS": DATABASE_OPTIONS,
Expand Down Expand Up @@ -465,7 +473,7 @@ def SITE_URL():

# There used to be a default password for zip files but for security reasons, it was removed. Trying to export
# without a password defined is going to fail
MASTER_DATA_PASSWORD = os.environ.get("MASTER_DATA_PASSWORD", None)
MASTER_DATA_PASSWORD = get_secret("MASTER_DATA_PASSWORD", None)

FRONTEND_URL = os.environ.get("FRONTEND_URL", "")

Expand Down