mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Add startup warning when SECRET_KEY is a known default (#2552)
This commit is contained in:
parent
b6c230d1cb
commit
92951a4f33
1 changed files with 18 additions and 0 deletions
|
|
@ -108,6 +108,24 @@ def create_app(config=None):
|
|||
logger.info(f"Configuration: {config}")
|
||||
app.config.from_object(config)
|
||||
logger.info(f"SPECTER_DATA_FOLDER: {app.config['SPECTER_DATA_FOLDER']}")
|
||||
|
||||
# Warn if someone is running with a default SECRET_KEY on a non-localhost address.
|
||||
# This can happen if SPECTER_CONFIG isn't set and someone accidentally ships with DevelopmentConfig.
|
||||
_insecure_defaults = ("development key", "test key")
|
||||
if app.config.get("SECRET_KEY") in _insecure_defaults:
|
||||
host = app.config.get("HOST", "127.0.0.1")
|
||||
if host not in ("127.0.0.1", "localhost", "0.0.0.0"):
|
||||
logger.warning(
|
||||
"WARNING: SECRET_KEY is set to a known default value and HOST is '%s'. "
|
||||
"This is insecure for anything other than local development. "
|
||||
"Please use ProductionConfig or set a proper SECRET_KEY.",
|
||||
host,
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"Running with a default SECRET_KEY. Fine for local dev, not for production."
|
||||
)
|
||||
|
||||
# Might be convenient to know later where it came from (see Service configuration)
|
||||
app.config["SPECTER_CONFIGURATION_CLASS_FULLNAME"] = config_name
|
||||
if not app.config.get("ENABLE_WERZEUG_REQUEST_LOGGING"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue