implements a way to skip over certain ips in rate limiter
This commit is contained in:
@@ -14,6 +14,9 @@ const middleware = (payload) => [
|
||||
rateLimit({
|
||||
windowMs: payload.config.rateLimit.window,
|
||||
max: payload.config.rateLimit.max,
|
||||
skip(req) {
|
||||
return payload.config.rateLimit.whitelist.includes(req.ip);
|
||||
},
|
||||
}),
|
||||
passport.initialize(),
|
||||
identifyAPI('REST'),
|
||||
|
||||
@@ -46,6 +46,7 @@ const sanitizeConfig = (config) => {
|
||||
sanitizedConfig.rateLimit = config.rateLimit || {};
|
||||
sanitizedConfig.rateLimit.window = sanitizedConfig.rateLimit.window || 15 * 60 * 100; // 15min default
|
||||
sanitizedConfig.rateLimit.max = sanitizedConfig.rateLimit.max || 100;
|
||||
sanitizedConfig.rateLimit.whitelist = sanitizedConfig.rateLimit.max || [];
|
||||
|
||||
sanitizedConfig.components = { ...(config.components || {}) };
|
||||
sanitizedConfig.hooks = { ...(config.hooks || {}) };
|
||||
|
||||
Reference in New Issue
Block a user