Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable26] fix: Properly throttle in error cases and add rate limit for public file creation #4205

Open
wants to merge 1 commit into
base: stable26
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading