Merge pull request #484 from sharelatex/ho-rate-limit-compiles

added rate limit to compile endpoint
This commit is contained in:
Henry Oswald 2017-04-25 09:17:27 +01:00 committed by GitHub
commit efe5e9efb0
3 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -328,6 +328,10 @@ div.full-size.pdf(ng-controller="PdfController")
.alert.alert-danger(ng-show="pdf.compileTerminated")
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

View file

@ -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