aboutsummaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2023-10-18 14:46:40 +0200
committerMarcel Klehr <mklehr@gmx.net>2023-10-18 14:46:40 +0200
commit6238aca6c50547b97a1c48cc897822601c114f15 (patch)
tree2cd5e584399880b5b1e28b622e33a3dbb358b389 /core/Controller
parente57e94e11a2b25b114a8da28ca363bab23d3b12b (diff)
downloadnextcloud-server-6238aca6c50547b97a1c48cc897822601c114f15.tar.gz
nextcloud-server-6238aca6c50547b97a1c48cc897822601c114f15.zip
fix(TextToImage): Fix bruteforce protection
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/TextToImageApiController.php29
1 files changed, 10 insertions, 19 deletions
diff --git a/core/Controller/TextToImageApiController.php b/core/Controller/TextToImageApiController.php
index 08d9a6b5776..921b3cbfb11 100644
--- a/core/Controller/TextToImageApiController.php
+++ b/core/Controller/TextToImageApiController.php
@@ -113,8 +113,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 404: Task not found
*/
#[PublicPage]
- #[BruteForceProtection(action: 'not-found')]
- #[BruteForceProtection(action: 'error')]
+ #[BruteForceProtection(action: 'text2image')]
public function getTask(int $id): DataResponse {
try {
$task = $this->textToImageManager->getUserTask($id, $this->userId);
@@ -126,12 +125,10 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
]);
} catch (TaskNotFoundException) {
$res = new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
- $res->throttle(['action' => 'not-found']);
+ $res->throttle(['action' => 'text2image']);
return $res;
} catch (\RuntimeException) {
- $res = new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
- $res->throttle(['action' => 'error']);
- return $res;
+ return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
@@ -146,8 +143,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 404: Task or image not found
*/
#[PublicPage]
- #[BruteForceProtection(action: 'not-found')]
- #[BruteForceProtection(action: 'error')]
+ #[BruteForceProtection(action: 'text2image')]
public function getImage(int $id): DataResponse|FileDisplayResponse {
try {
$task = $this->textToImageManager->getUserTask($id, $this->userId);
@@ -162,15 +158,13 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => image_type_to_mime_type($info[2])]);
} catch (TaskNotFoundException) {
$res = new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
- $res->throttle(['action' => 'not-found']);
+ $res->throttle(['action' => 'text2image']);
return $res;
} catch (\RuntimeException) {
- $res = new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
- $res->throttle(['action' => 'error']);
- return $res;
+ return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
} catch (NotFoundException) {
$res = new DataResponse(['message' => $this->l->t('Image not found')], Http::STATUS_NOT_FOUND);
- $res->throttle(['action' => 'not-found']);
+ $res->throttle(['action' => 'text2image']);
return $res;
}
}
@@ -186,8 +180,7 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
* 404: Task not found
*/
#[NoAdminRequired]
- #[BruteForceProtection(action: 'not-found')]
- #[BruteForceProtection(action: 'error')]
+ #[BruteForceProtection(action: 'text2image')]
public function deleteTask(int $id): DataResponse {
try {
$task = $this->textToImageManager->getUserTask($id, $this->userId);
@@ -201,12 +194,10 @@ class TextToImageApiController extends \OCP\AppFramework\OCSController {
]);
} catch (TaskNotFoundException) {
$res = new DataResponse(['message' => $this->l->t('Task not found')], Http::STATUS_NOT_FOUND);
- $res->throttle(['action' => 'not-found']);
+ $res->throttle(['action' => 'text2image']);
return $res;
} catch (\RuntimeException) {
- $res = new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
- $res->throttle(['action' => 'error']);
- return $res;
+ return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}