mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
rate limit via ip the number of invite to project requests
This commit is contained in:
parent
6d35585847
commit
74240e28c7
2 changed files with 11 additions and 2 deletions
|
@ -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(),
|
||||
|
|
|
@ -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)->
|
||||
|
|
Loading…
Reference in a new issue