fix(config): now loading config from env correctly

This commit is contained in:
2021-11-29 15:26:28 +01:00
parent a1d5bce066
commit 7c3fac227f
2 changed files with 35 additions and 8 deletions

31
app/config.py Normal file
View File

@@ -0,0 +1,31 @@
import os
class Config(object):
SECRET_KEY = os.environ.get("SECRET_KEY")
if SECRET_KEY is None:
raise Exception("[!!] No secret key was given")
LDAP_ADDRESS = os.environ.get("LDAP_ADDRESS")
if LDAP_ADDRESS is None:
raise Exception("[!!] No LDAP_ADDRESS was given")
LDAP_PORT = os.environ.get("LDAP_PORT", default=389)
_ldap_tls = os.environ.get("LDAP_TLS", default=False)
LDAP_TLS = _ldap_tls.lower() in {"1", "t", "true"}
BASE_DN = os.environ.get("BASE_DN")
if BASE_DN is None:
raise Exception("[!!] No BASE_DN was given")
CSRF_ENABLED = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'None'
class DevelopmentConfig(Config):
TESTING = True
DEBUG = True
DEVELOPMENT = True
class ProductionConfig(Config):
TESTING = False
DEBUG = False