From db9ae59c8a4b045eaf8e34a4bfc375d7d1cf21f1 Mon Sep 17 00:00:00 2001 From: Alex Arvanitidis Date: Thu, 19 Dec 2024 16:13:56 +0200 Subject: [PATCH] fix: rate limit streaming prediction --- src/main/kotlin/org/jaqpot/api/service/model/ModelService.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/org/jaqpot/api/service/model/ModelService.kt b/src/main/kotlin/org/jaqpot/api/service/model/ModelService.kt index 61e0747..b44a041 100644 --- a/src/main/kotlin/org/jaqpot/api/service/model/ModelService.kt +++ b/src/main/kotlin/org/jaqpot/api/service/model/ModelService.kt @@ -290,6 +290,11 @@ class ModelService( throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Unknown dataset type", null) } + @PreAuthorize("@predictModelAuthorizationLogic.decide(#root, #modelId)") + @WithRateLimitProtectionByUser( + limit = 30, + intervalInSeconds = 60 * 60 + ) // 30 requests per hour, up to 100 predictions per request fun streamPredictWithModel( modelId: Long, datasetId: Long,