patx/projectpay

Rate limit login path aliases consistently

Commit 1712efe · patx · Nov 3 at 6:53AM

Changeset
1712efe2a167b6d006cce297adf0e90cf133e957
Parents
79b4e2acc527377702f7192dbf233244c03d4835

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/deploy/README.md b/deploy/README.md
index 91d97e6..1dbf4a1 100644
--- a/deploy/README.md
+++ b/deploy/README.md
@@ -49,7 +49,8 @@ unchanged through migration; nginx was gracefully reloaded.
 
 The dedicated vhost enforces TLS, HSTS, no-store responses, sanitized proxy
 headers, 128 KiB form bodies, a separate 1 MiB Stripe webhook allowance, timeouts,
-rate limits, and connection limits. Webhooks have a separate higher rate bucket
+rate limits, and connection limits. Login POSTs and their trailing-slash aliases
+share one per-client auth bucket, using nginx's normalized URI. Webhooks have a separate higher rate bucket
 and are never retried automatically to another upstream. Existing application
 CSP, frame protection, secure cookies, CSRF, and webhook verification remain active.
 
diff --git a/deploy/projectpay-http.conf b/deploy/projectpay-http.conf
index 3156f92..cf52f4b 100644
--- a/deploy/projectpay-http.conf
+++ b/deploy/projectpay-http.conf
@@ -1,7 +1,7 @@
 # Install as /etc/nginx/conf.d/projectpay.conf (http context).
 map "$request_method:$uri" $projectpay_auth_key {
     default "";
-    "POST:/login" $binary_remote_addr;
+    ~^POST:/login/*$ $binary_remote_addr;
 }
 limit_req_zone $binary_remote_addr zone=projectpay_requests:10m rate=20r/s;
 limit_req_zone $projectpay_auth_key zone=projectpay_auth:10m rate=10r/m;