Rate-limit /api/challenge endpoint

This commit is contained in:
Clay 2026-12-03 15:45:05 -05:00
parent 0438a5fd5f
commit d34eac97c7

View file

@ -82,6 +82,13 @@ const loginLimiter = rateLimit({
legacyHeaders: false, legacyHeaders: false,
message: { error: 'Too many login attempts, try again later.' }, message: { error: 'Too many login attempts, try again later.' },
}); });
const challengeLimiter = rateLimit({
windowMs: 15 * 60 * 1000,
limit: 30,
standardHeaders: 'draft-7',
legacyHeaders: false,
message: { error: 'Too many challenge requests, try again later.' },
});
const apiLimiter = rateLimit({ const apiLimiter = rateLimit({
windowMs: 60 * 1000, windowMs: 60 * 1000,
limit: 120, limit: 120,
@ -91,6 +98,7 @@ const apiLimiter = rateLimit({
}); });
app.use('/api', apiLimiter); app.use('/api', apiLimiter);
app.use('/api/login', loginLimiter); app.use('/api/login', loginLimiter);
app.use('/api/challenge', challengeLimiter);
app.use('/api', (_req, res, next) => { app.use('/api', (_req, res, next) => {
res.set('Cache-Control', 'no-store'); res.set('Cache-Control', 'no-store');