aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorDennis Fink2026-10-30 08:35:46 +0100
committerDennis Fink2026-10-30 08:41:42 +0100
commit4485aeb573ceb37237ea1fbc80665ed6c4136116 (patch)
treebce18a2c7fadd657d9f9809ebbc65d06c6cc4dc4 /contrib
parent9f093cf07a3531ee4b7d02c20151e21c141a93de (diff)
downloadwebmentions-ssg-4485aeb573ceb37237ea1fbc80665ed6c4136116.tar.gz
webmentions-ssg-4485aeb573ceb37237ea1fbc80665ed6c4136116.zip
fix(core): harden application configuration
Fail production startup when required configuration is missing, normalize allowed hostnames before validation, and move shared request limits into the default configuration so production does not depend on testing-only values. Set secure session cookie defaults while preserving explicit overrides and document the new rate-limit and notification settings in the example config.
Diffstat (limited to '')
-rw-r--r--contrib/webmentions-ssg.example.cfg37
1 files changed, 21 insertions, 16 deletions
diff --git a/contrib/webmentions-ssg.example.cfg b/contrib/webmentions-ssg.example.cfg
index d92726e..d214312 100644
--- a/contrib/webmentions-ssg.example.cfg
+++ b/contrib/webmentions-ssg.example.cfg
@@ -15,27 +15,13 @@ BOOTSTRAP_SERVE_LOCAL = True
# BOOTSTRAP_BOOTSWATCH_THEME = "Materia"
# ---------------------------------------------------------------------------
-# Flask / Security
+# Flask / Security
# ---------------------------------------------------------------------------
-# Generate a persistent random key, e.g.:
+# Generate a persistent random key, e.g.:
# python -c 'import secrets; print(secrets.token_urlsafe(32))'
# Never commit your real key or SMTP password to version control.
SECRET_KEY = "REPLACE_WITH_A_LONG_RANDOM_SECRET"
-# Only transmit session cookies over HTTPS connections.
-# Recommended for production deployments using HTTPS.
-# Set to False only when developing locally over plain HTTP.
-SESSION_COOKIE_SECURE = True
-
-# Prevent JavaScript from accessing session cookies via document.cookie.
-# Helps protect session cookies from theft through XSS attacks.
-SESSION_COOKIE_HTTPONLY = True
-
-# Restrict session cookies to same-site requests to help mitigate CSRF.
-# "Lax" allows normal navigation from external sites while restricting
-# cookies on most cross-site requests.
-SESSION_COOKIE_SAMESITE = "Lax"
-
# ---------------------------------------------------------------------------
# Database and logging
# ---------------------------------------------------------------------------
@@ -64,6 +50,23 @@ MAX_REDIRECTS = 20 # also used for outgoing requests
MAX_SOURCE_BYTES = 1_000_000
# ---------------------------------------------------------------------------
+# Rate limiting
+# ---------------------------------------------------------------------------
+# In-memory storage is for development/testing ONLY. Production requires shared
+# storage, such as Redis, or the application will refuse to start.
+RATELIMIT_STORAGE_URI = "memory://"
+RATELIMIT_HEADERS_ENABLED = True
+
+# Limits per client and across all clients for incoming Webmention submissions.
+ENDPOINT_RATE_LIMIT = "10/minute;100/hour"
+ENDPOINT_GLOBAL_RATE_LIMIT = "1000/hour"
+# Minimum seconds between verifications of the same source/target pair.
+ENDPOINT_REVERIFY_COOLDOWN_SECONDS = 600
+
+# Limit login POST attempts per client.
+LOGIN_RATE_LIMIT = "5/minute;30/hour"
+
+# ---------------------------------------------------------------------------
# Sending Webmentions from a statically generated site
# ---------------------------------------------------------------------------
# Folder containing generated pages named index.html. Set to None to disable
@@ -92,6 +95,8 @@ HUEY_URL = "redis://127.0.0.1:6379/0"
# ---------------------------------------------------------------------------
# Set NOTIFICATION_EMAIL = None to disable notification emails.
NOTIFICATION_EMAIL = "admin@example.com"
+# Daily notification digest at 08:00 UTC (Huey defaults to UTC).
+NOTIFICATION_SCHEDULE = "0 8 * * *"
# Example SMTP-over-STARTTLS setup; adapt to your mail provider.
MAIL_SERVER = "smtp.example.com"