Skip to content

Commit

Permalink
refactor: Replace security annotations with attributes in LogController
Browse files Browse the repository at this point in the history
Signed-off-by: Josh <[email protected]>
  • Loading branch information
joshtrichards authored Oct 5, 2024
1 parent 22a232a commit 88286bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Controller/LogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 88286bc

Please sign in to comment.