From 88286bca934bd5449d876eb216ba1a5ec9cb8bda Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 5 Oct 2024 08:39:33 -0400 Subject: [PATCH] refactor: Replace security annotations with attributes in LogController Signed-off-by: Josh --- lib/Controller/LogController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Controller/LogController.php b/lib/Controller/LogController.php index 713b060a..ce1c91a3 100644 --- a/lib/Controller/LogController.php +++ b/lib/Controller/LogController.php @@ -9,8 +9,10 @@ use OCA\LogReader\Log\LogIteratorFactory; use OCA\LogReader\Log\SearchFilter; use OCA\LogReader\Service\SettingsService; +use OCA\LogReader\Settings\Admin; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use Psr\Log\LoggerInterface; @@ -32,12 +34,12 @@ public function __construct($appName, } /** - * @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin) * @param string $query * @param int $count * @param int $offset * @return JSONResponse */ + #[AuthorizedAdminSetting(settings: Admin::class)] public function get($query = '', $count = 50, $offset = 0): JSONResponse { $logType = $this->settingsService->getLoggingType(); // we only support web access when `log_type` is set to `file` (the default) @@ -70,7 +72,6 @@ private function getLastItem() { } /** - * @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin) * @brief Use to poll for new log messages since $lastReqId. * * @note There is a possible race condition, when the user loads the @@ -83,6 +84,7 @@ private function getLastItem() { * will work in some cases but not when there are more than 50 messages of that * request. */ + #[AuthorizedAdminSetting(settings: Admin::class)] public function poll(string $lastReqId): JSONResponse { $logType = $this->settingsService->getLoggingType(); // we only support web access when `log_type` is set to `file` (the default)