From 3494eab1208dc18478485e02c61e292556502fa6 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sat, 31 Oct 2026 16:42:44 +0100 Subject: fix(core): harden session and credential security Require persistent non-placeholder signing keys outside local development and bind login sessions to the current password hash so password changes revoke existing cookies. Enforce a minimal password policy for user administration while preserving long Unicode passphrases without arbitrary composition limits. --- webmentions_ssg/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'webmentions_ssg/config.py') diff --git a/webmentions_ssg/config.py b/webmentions_ssg/config.py index 1c7d44e..28cea64 100644 --- a/webmentions_ssg/config.py +++ b/webmentions_ssg/config.py @@ -5,7 +5,6 @@ """Define application settings for production, development, and testing.""" import logging -import secrets def normalize_allowed_hostnames(value: object) -> set[str]: @@ -26,7 +25,8 @@ def normalize_allowed_hostnames(value: object) -> set[str]: class DefaultConfig: TESTING = False DEBUG = False - SECRET_KEY = secrets.token_urlsafe() + # Production must provide a persistent, random key through configuration. + SECRET_KEY = None BOOTSTRAP_SERVE_LOCAL = True # BOOTSTRAP_BOOTSWATCH_THEME = "Materia" # Secure by default; deployment configuration can override these values. @@ -82,6 +82,8 @@ class DefaultConfig: class DevelopmentConfig(DefaultConfig): DEBUG = True + # Only for local debug use; production rejects this as an insecure value. + SECRET_KEY = "INSECURE_DEVELOPMENT_ONLY_SECRET_KEY" SESSION_COOKIE_SECURE = False LOG_FILE = "testing/webmentions-ssg.log" LOG_LEVEL = logging.DEBUG -- cgit v1.3.1