Skip to content

Commit

Permalink
Merge pull request #1385 from nextcloud/jtr/refactor-deprecated-sec-a…
Browse files Browse the repository at this point in the history
…nnotations
  • Loading branch information
provokateurin authored Oct 6, 2024
2 parents 36db06b + 88286bc commit b773296
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 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
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

0 comments on commit b773296

Please sign in to comment.