Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replace security annotations with respective attributes #1385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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
7 changes: 4 additions & 3 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

use OCA\LogReader\Constants;
use OCA\LogReader\Service\SettingsService;
use OCA\LogReader\Settings\Admin;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IConfig;
use OCP\IRequest;
Expand All @@ -31,9 +33,8 @@ public function __construct(

/**
* Get the current app config
*
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
*/
#[AuthorizedAdminSetting(settings: Admin::class)]
public function getAppConfig(): JSONResponse {
return new JSONResponse($this->settingsService->getAppSettings());
}
Expand All @@ -44,8 +45,8 @@ public function getAppConfig(): JSONResponse {
* @param string $settingsKey AppConfig Key to store
* @param mixed $settingsValues Corresponding AppConfig Value
*
* @AuthorizedAdminSetting(settings=OCA\LogReader\Settings\Admin)
*/
#[AuthorizedAdminSetting(settings: Admin::class)]
public function updateAppConfig(string $settingsKey, $settingsValue): JSONResponse {
$this->logger->debug('Updating AppConfig: {settingsKey} => {settingsValue}', [
'settingsKey' => $settingsKey,
Expand Down
Loading