feat: add custom rate limiting for mfa

This commit is contained in:
Sheen Capadngan
2024-05-22 23:51:58 +08:00
parent e3dae9d498
commit 8ec8b1ce2f
2 changed files with 12 additions and 3 deletions
+9
View File
@@ -52,6 +52,15 @@ export const inviteUserRateLimit: RateLimitOptions = {
keyGenerator: (req) => req.realIp
};
export const mfaRateLimit: RateLimitOptions = {
timeWindow: 60 * 1000,
max: 20,
keyGenerator: (req) => {
// fallback to IP to avoid global rate limiting when authorization is set to empty
return req.headers.authorization?.split(" ")[1] || req.realIp;
}
};
export const creationLimit: RateLimitOptions = {
// identity, project, org
timeWindow: 60 * 1000,