Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
refactor: Replace security annotations with attributes in LogController
Signed-off-by: Josh <[email protected]>
  • Loading branch information
joshtrichards authored Oct 5, 2024
commit 88286bca934bd5449d876eb216ba1a5ec9cb8bda
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