Skip to content

Commit

Permalink
Merge pull request #4203 from nextcloud/backport/4200/stable28
Browse files Browse the repository at this point in the history
[stable28] fix: Properly throttle in error cases and add rate limit for public file creation
  • Loading branch information
juliusknorr authored Nov 7, 2024
2 parents a350914 + ccd7f94 commit 93dfa6b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Controller/DocumentAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function __construct(IRequest $request, IRootFolder $rootFolder, IManager
* @NoAdminRequired
* @PublicPage
* @BruteForceProtection(action=richdocumentsCreatePublic)
* @AnonRateThrottle(limit: 5, period: 120)
*/
public function create(string $mimeType, string $fileName, string $directoryPath = '/', string $shareToken = null, ?int $templateId = null): JSONResponse {
try {
Expand Down Expand Up @@ -105,10 +106,12 @@ public function create(string $mimeType, string $fileName, string $directoryPath
}
} catch (Throwable $e) {
$this->logger->error('Failed to create document', ['exception' => $e]);
return new JSONResponse([
$response = new JSONResponse([
'status' => 'error',
'message' => $this->l10n->t('Cannot create document')
], Http::STATUS_BAD_REQUEST);
$response->throttle();
return $response;
}

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

0 comments on commit 93dfa6b

Please sign in to comment.