projects
/
styx.blog
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7a77de2
)
Change method of storing secrets
author
David Kerkeslager
<kerkeslager@gmail.com>
Thu, 13 Aug 2020 02:02:49 +0000
(22:02 -0400)
committer
David Kerkeslager
<kerkeslager@gmail.com>
Thu, 13 Aug 2020 02:02:49 +0000
(22:02 -0400)
styx/settings.py
patch
|
blob
|
history
diff --git
a/styx/settings.py
b/styx/settings.py
index
37af17a
..
e647c67
100644
(file)
--- a/
styx/settings.py
+++ b/
styx/settings.py
@@
-11,6
+11,7
@@
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
"""
from pathlib import Path
+import json
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@
-20,15
+21,20
@@
BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
-# SECURITY WARNING: keep the secret key used in production secret!
+try:
+ with open('~/.styxrc', 'r') as styxrc:
+ LOCAL_SETTINGS = json.loads(styxrc.read())
+
+except FileNotFoundError:
+ LOCAL_SETTINGS = {}
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG =
(os.environ.get('STYX_DEBUG', 'true') == 'true'
)
+DEBUG =
LOCAL_SETTINGS.get('DEBUG', True
)
if DEBUG:
SECRET_KEY = 'mq@_9a6&y4nvgqa7obf-r%a4^dt)z=r8jr&91&=oc^6-=i0*$z'
else:
if DEBUG:
SECRET_KEY = 'mq@_9a6&y4nvgqa7obf-r%a4^dt)z=r8jr&91&=oc^6-=i0*$z'
else:
- SECRET_KEY =
os.environ['STYX_
SECRET_KEY']
+ SECRET_KEY =
LOCAL_SETTINGS['
SECRET_KEY']
ALLOWED_HOSTS = [
'localhost',
ALLOWED_HOSTS = [
'localhost',
@@
-95,7
+101,7
@@
else:
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'styx',
'USER': 'styxuser',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'styx',
'USER': 'styxuser',
- 'PASSWORD':
os.environ['STYX_
DB_PASSWORD'],
+ 'PASSWORD':
LOCAL_SETTINGS['
DB_PASSWORD'],
}
}
}
}