diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsRouter.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsRouter.coffee index 4c7cc8c76a..8b130d27db 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsRouter.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsRouter.coffee @@ -24,7 +24,13 @@ module.exports = RateLimiterMiddlewear.rateLimit({ endpointName: "invite-to-project" params: ["Project_id"] - maxRequests: 200 + maxRequests: 100 + timeInterval: 60 * 10 + }), + RateLimiterMiddlewear.rateLimit({ + endpointName: "invite-to-project-ip" + ipOnly:true + maxRequests: 100 timeInterval: 60 * 10 }), AuthenticationController.requireLogin(), diff --git a/services/web/app/coffee/Features/Security/RateLimiterMiddlewear.coffee b/services/web/app/coffee/Features/Security/RateLimiterMiddlewear.coffee index f486e94493..04b81581bf 100644 --- a/services/web/app/coffee/Features/Security/RateLimiterMiddlewear.coffee +++ b/services/web/app/coffee/Features/Security/RateLimiterMiddlewear.coffee @@ -19,12 +19,15 @@ module.exports = RateLimiterMiddlewear = user_id = AuthenticationController.getLoggedInUserId(req) || req.ip params = (opts.params or []).map (p) -> req.params[p] params.push user_id + subjectName = params.join(":") + if opts.ipOnly + subjectName = req.ip if !opts.endpointName? throw new Error("no endpointName provided") options = { endpointName: opts.endpointName timeInterval: opts.timeInterval or 60 - subjectName: params.join(":") + subjectName: subjectName throttle: opts.maxRequests or 6 } RateLimiter.addCount options, (error, canContinue)->