Merge pull request #3414 from overleaf/jpa-rate-limit-downloads

[misc] add rate-limits to download routes of mics output files

GitOrigin-RevId: d1d646fc3da6b628adc762ce84860e3701e3857d
This commit is contained in:
Jakob Ackermann 2020-11-26 12:55:22 +00:00 committed by Copybot
parent d7f32179e4
commit 500a7b60e0

View file

@ -368,6 +368,14 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
CompileController.downloadPdf
)
// Align with limits defined in CompileController.downloadPdf
const rateLimiterMiddlewareOutputFiles = RateLimiterMiddleware.rateLimit({
endpointName: 'misc-output-download',
params: ['Project_id'],
maxRequests: 1000,
timeInterval: 60 * 60
})
// Used by the pdf viewers
webRouter.get(
/^\/project\/([^/]*)\/output\/(.*)$/,
@ -379,6 +387,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
req.params = params
next()
},
rateLimiterMiddlewareOutputFiles,
AuthorizationMiddleware.ensureUserCanReadProject,
CompileController.getFileFromClsi
)
@ -394,6 +403,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
req.params = params
next()
},
rateLimiterMiddlewareOutputFiles,
AuthorizationMiddleware.ensureUserCanReadProject,
CompileController.getFileFromClsi
)
@ -410,6 +420,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
req.params = params
next()
},
rateLimiterMiddlewareOutputFiles,
AuthorizationMiddleware.ensureUserCanReadProject,
CompileController.getFileFromClsi
)
@ -427,6 +438,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
req.params = params
next()
},
rateLimiterMiddlewareOutputFiles,
AuthorizationMiddleware.ensureUserCanReadProject,
CompileController.getFileFromClsi
)