aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg/__init__.py')
-rw-r--r--webmentions_ssg/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/webmentions_ssg/__init__.py b/webmentions_ssg/__init__.py
index 518add0..51635ef 100644
--- a/webmentions_ssg/__init__.py
+++ b/webmentions_ssg/__init__.py
@@ -27,6 +27,7 @@ from webmentions_ssg.config import (
normalize_allowed_hostnames,
)
+from .security import validate_secret_key
from .tasks import Huey
from .url_security import is_http_url
@@ -82,6 +83,16 @@ def create_app(config_class: type[DefaultConfig] | None = None) -> Flask:
app.config.from_prefixed_env(prefix="FLASK")
app.config.from_prefixed_env(prefix="WEBMENTIONS_SSG")
+ # A fixed key is convenient only for local debugging. All other
+ # deployments must supply their own persistent, random signing key.
+ using_local_dev_key = (
+ issubclass(config_class, DevelopmentConfig)
+ and app.debug
+ and app.config.get("SECRET_KEY") == DevelopmentConfig.SECRET_KEY
+ )
+ if not app.testing and not using_local_dev_key:
+ validate_secret_key(app.config.get("SECRET_KEY"))
+
app.config["ALLOWED_HOSTNAMES"] = normalize_allowed_hostnames(
app.config["ALLOWED_HOSTNAMES"]
)