feat: replace fixed login rate limit with progressive lockout

Made-with: Cursor
This commit is contained in:
Anton
2026-03-04 17:55:25 +03:00
parent e3d7f1d24c
commit dcc4fd370a
5 changed files with 141 additions and 15 deletions

View File

@@ -6,7 +6,6 @@ import { env } from '../config/env.js';
declare module 'fastify' {
interface FastifyInstance {
rateLimitOptions: {
login: { max: number; timeWindow: string };
register: { max: number; timeWindow: string };
forgotPassword: { max: number; timeWindow: string };
verifyEmail: { max: number; timeWindow: string };
@@ -18,7 +17,6 @@ declare module 'fastify' {
const rateLimitPlugin: FastifyPluginAsync = async (app: FastifyInstance) => {
const options = {
login: { max: env.RATE_LIMIT_LOGIN, timeWindow: '15 minutes' },
register: { max: env.RATE_LIMIT_REGISTER, timeWindow: '1 hour' },
forgotPassword: { max: env.RATE_LIMIT_FORGOT_PASSWORD, timeWindow: '1 hour' },
verifyEmail: { max: env.RATE_LIMIT_VERIFY_EMAIL, timeWindow: '15 minutes' },