detached e6d2489

feat: Adjust rate limiting configuration for authentication endpoints

- Increase auth endpoint rate limit from 5 to 20 requests per 5 minutes
- Add debug logging for rate limit checks to aid in monitoring and troubleshooting
- Provide more visibility into rate limiting behavior with detailed console debug message
commit
e6d248973bf9af2ed7a2655c7063cfeedd0f562b
author
Kit · · 2025-02-14 13:14 UTC
parent
5367de1
signature
SSH UnverifiedSHA256:H91DFuEG4jpk5edzLA4aUKkpv4zv9Q339ipRmkph6Tk The key is unknown
1 file · +3 -1
M src/lib/api/rate-limiter.ts +3 -1
@@ -3,7 +3,7 @@ import type { RequestEvent } from '@sveltejs/kit';
33 // Rate limit configuration by endpoint type
44 const RATE_LIMITS = {
55 // Authentication endpoints (login, register)
6- auth: { points: 5, durationMs: 5 * 60 * 1000 }, // 5 requests per 5 minutes
6+ auth: { points: 20, durationMs: 5 * 60 * 1000 }, // 20 requests per 5 minutes
77
88 // Public endpoints (public chat, rooms)
99 public: { points: 30, durationMs: 60 * 1000 }, // 30 requests per minute
@@ -82,6 +82,8 @@ function isRateLimited(ip: string, endpointType: keyof typeof RATE_LIMITS, isAut
8282 const requests = ipRequests.get(ip) || [];
8383 const validRequests = requests.filter(req => now - req.timestamp < durationMs);
8484
85+ console.debug(`Rate limit check for ${ip} on ${endpointType}: ${validRequests.length}/${points} requests in the last ${durationMs/1000}s`);
86+
8587 if (validRequests.length >= points) {
8688 const oldestRequest = validRequests[0];
8789 const retryAfter = durationMs - (now - oldestRequest.timestamp);
@@ -3,7 +3,7 @@ import type { RequestEvent } from '@sveltejs/kit';
3 // Rate limit configuration by endpoint type3 // Rate limit configuration by endpoint type
4 const RATE_LIMITS = {4 const RATE_LIMITS = {
5 // Authentication endpoints (login, register)5 // Authentication endpoints (login, register)
6- auth: { points: 5, durationMs: 5 * 60 * 1000 }, // 5 requests per 5 minutes6+ auth: { points: 20, durationMs: 5 * 60 * 1000 }, // 20 requests per 5 minutes
7 7
8 // Public endpoints (public chat, rooms)8 // Public endpoints (public chat, rooms)
9 public: { points: 30, durationMs: 60 * 1000 }, // 30 requests per minute9 public: { points: 30, durationMs: 60 * 1000 }, // 30 requests per minute
@@ -82,6 +82,8 @@ function isRateLimited(ip: string, endpointType: keyof typeof RATE_LIMITS, isAut
82 const requests = ipRequests.get(ip) || [];82 const requests = ipRequests.get(ip) || [];
83 const validRequests = requests.filter(req => now - req.timestamp < durationMs);83 const validRequests = requests.filter(req => now - req.timestamp < durationMs);
84 84
85+ console.debug(`Rate limit check for ${ip} on ${endpointType}: ${validRequests.length}/${points} requests in the last ${durationMs/1000}s`);
86+
85 if (validRequests.length >= points) {87 if (validRequests.length >= points) {
86 const oldestRequest = validRequests[0];88 const oldestRequest = validRequests[0];
87 const retryAfter = durationMs - (now - oldestRequest.timestamp);89 const retryAfter = durationMs - (now - oldestRequest.timestamp);

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 3

Tags 8

↑↓ moveenter openesc close