From 89507cfa0aee0d26e19c27de2c9daa01b7631c16 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 8 Aug 2023 14:36:10 +0200 Subject: [PATCH] fix(proxy): Add image proxy rate limit Signed-off-by: Christoph Wurst --- lib/Controller/ProxyController.php | 3 +++ psalm.xml | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/Controller/ProxyController.php b/lib/Controller/ProxyController.php index cf17ed9569..eb00b39c1a 100644 --- a/lib/Controller/ProxyController.php +++ b/lib/Controller/ProxyController.php @@ -29,6 +29,7 @@ use Exception; use OCA\Mail\Http\ProxyDownloadResponse; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\UserRateLimit; use OCP\AppFramework\Http\TemplateResponse; use OCP\Http\Client\IClientService; use OCP\IRequest; @@ -93,6 +94,7 @@ public function redirect(string $src): TemplateResponse { /** * @NoAdminRequired * @NoCSRFRequired + * @UserRateThrottle(limit=50, period=60) * * @param string $src * @@ -102,6 +104,7 @@ public function redirect(string $src): TemplateResponse { * * @return ProxyDownloadResponse */ + #[UserRateLimit(limit: 50, period: 60)] public function proxy(string $src): ProxyDownloadResponse { // close the session to allow parallel downloads $this->session->close(); diff --git a/psalm.xml b/psalm.xml index fd9c98b5f0..55ee9a4ffb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -19,6 +19,11 @@ + + + + +