mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #484 from sharelatex/ho-rate-limit-compiles
added rate limit to compile endpoint
This commit is contained in:
commit
efe5e9efb0
3 changed files with 14 additions and 2 deletions
|
@ -111,7 +111,13 @@ module.exports = class Router
|
|||
webRouter.post '/project/:Project_id/settings', AuthorizationMiddlewear.ensureUserCanWriteProjectSettings, ProjectController.updateProjectSettings
|
||||
webRouter.post '/project/:Project_id/settings/admin', AuthorizationMiddlewear.ensureUserCanAdminProject, ProjectController.updateProjectAdminSettings
|
||||
|
||||
webRouter.post '/project/:Project_id/compile', AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.compile
|
||||
webRouter.post '/project/:Project_id/compile', RateLimiterMiddlewear.rateLimit({
|
||||
endpointName: "compile-project-http"
|
||||
params: ["Project_id"]
|
||||
maxRequests: 800
|
||||
timeInterval: 60 * 60
|
||||
}), AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.compile
|
||||
|
||||
webRouter.post '/project/:Project_id/compile/stop', AuthorizationMiddlewear.ensureUserCanReadProject, CompileController.stopCompile
|
||||
|
||||
# Used by the web download buttons, adds filename header
|
||||
|
|
|
@ -329,6 +329,10 @@ div.full-size.pdf(ng-controller="PdfController")
|
|||
strong #{translate("terminated")}.
|
||||
span #{translate("compile_terminated_by_user")}
|
||||
|
||||
.alert.alert-danger(ng-show="pdf.rateLimited")
|
||||
strong #{translate("pdf_compile_rate_limit_hit")}
|
||||
span #{translate("project_flagged_too_many_compiles")}
|
||||
|
||||
.alert.alert-danger(ng-show="pdf.timedout")
|
||||
p
|
||||
strong #{translate("timedout")}.
|
||||
|
|
|
@ -388,7 +388,9 @@ define [
|
|||
$scope.pdf.view = "pdf"
|
||||
$scope.pdf.compiling = false
|
||||
parseCompileResponse(data)
|
||||
.error () ->
|
||||
.error (err, status) ->
|
||||
if status == 429
|
||||
$scope.pdf.rateLimited = true
|
||||
$scope.pdf.compiling = false
|
||||
$scope.pdf.renderingError = false
|
||||
$scope.pdf.error = true
|
||||
|
|
Loading…
Reference in a new issue