aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/config.py
diff options
context:
space:
mode:
authorDennis Fink2026-10-31 19:33:49 +0100
committerDennis Fink2026-10-31 19:33:49 +0100
commit3a3284abe23e143cbb638877f47958c82afa3367 (patch)
tree5409bb940d252756f502d545cc145b382f06a3a0 /webmentions_ssg/config.py
parent40bdba0f2aa132f47326d2591e83039249ae2121 (diff)
downloadwebmentions-ssg-3a3284abe23e143cbb638877f47958c82afa3367.tar.gz
webmentions-ssg-3a3284abe23e143cbb638877f47958c82afa3367.zip
fix(core): harden login rate limiting behind proxies
Trust forwarded client addresses only for an explicitly configured number of reverse-proxy hops so per-IP limits cannot be bypassed or collapsed in proxied deployments. Add a separate hashed per-username login limit across IPs to reduce distributed credential-guessing attempts without storing raw usernames in limiter keys.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/config.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/webmentions_ssg/config.py b/webmentions_ssg/config.py
index b1d588b..8a3e58d 100644
--- a/webmentions_ssg/config.py
+++ b/webmentions_ssg/config.py
@@ -98,6 +98,10 @@ class DefaultConfig:
MAIL_PASSWORD = None
MAIL_DEFAULT_SENDER = None
+ # Number of trusted reverse-proxy hops for X-Forwarded-For/Proto.
+ # 0 (default) means forwarded headers are not trusted.
+ PROXY_FIX_TRUSTED_HOPS = 0
+
RATELIMIT_STORAGE_URI = "memory://"
RATELIMIT_HEADERS_ENABLED = True
@@ -106,6 +110,8 @@ class DefaultConfig:
ENDPOINT_REVERIFY_COOLDOWN_SECONDS = 600
LOGIN_RATE_LIMIT = "5/minute;30/hour"
+ # Separate cross-IP limit for each submitted username (hashed in storage).
+ LOGIN_USERNAME_RATE_LIMIT = "20/minute;100/hour"
class DevelopmentConfig(DefaultConfig):