Skip to content

Commit 56facfb

Browse files
authored
Merge pull request #4205 from nextcloud/backport/4203/stable26
[stable26] fix: Properly throttle in error cases and add rate limit for public file creation
2 parents c5797a1 + ffb368c commit 56facfb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/Controller/DocumentAPIController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function __construct(IRequest $request, IRootFolder $rootFolder, IManager
7878
* @NoAdminRequired
7979
* @PublicPage
8080
* @BruteForceProtection(action=richdocumentsCreatePublic)
81+
* @AnonRateThrottle(limit: 5, period: 120)
8182
*/
8283
public function create(string $mimeType, string $fileName, string $directoryPath = '/', string $shareToken = null, ?int $templateId = null): JSONResponse {
8384
try {
@@ -105,10 +106,12 @@ public function create(string $mimeType, string $fileName, string $directoryPath
105106
}
106107
} catch (Throwable $e) {
107108
$this->logger->error('Failed to create document', ['exception' => $e]);
108-
return new JSONResponse([
109+
$response = new JSONResponse([
109110
'status' => 'error',
110111
'message' => $this->l10n->t('Cannot create document')
111112
], Http::STATUS_BAD_REQUEST);
113+
$response->throttle();
114+
return $response;
112115
}
113116

114117
$basename = $this->l10n->t('New Document.odt');

0 commit comments

Comments
 (0)