From f7c88210c13d9d10e37cb0b78e571361f8b4ac0a Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 25 Jul 2024 13:14:45 +0200 Subject: [PATCH] refactor(dav): Replace security annotations with respective attributes Signed-off-by: provokateurin --- .../Controller/BirthdayCalendarController.php | 6 +++-- apps/dav/lib/Controller/DirectController.php | 4 ++-- .../InvitationResponseController.php | 22 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/dav/lib/Controller/BirthdayCalendarController.php b/apps/dav/lib/Controller/BirthdayCalendarController.php index 8662030875824..e82c4ad534cd7 100644 --- a/apps/dav/lib/Controller/BirthdayCalendarController.php +++ b/apps/dav/lib/Controller/BirthdayCalendarController.php @@ -7,7 +7,9 @@ use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob; use OCA\DAV\CalDAV\CalDavBackend; +use OCA\DAV\Settings\CalDAVSettings; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Response; use OCP\BackgroundJob\IJobList; @@ -70,8 +72,8 @@ public function __construct($appName, IRequest $request, /** * @return Response - * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) */ + #[AuthorizedAdminSetting(settings: CalDAVSettings::class)] public function enable() { $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'yes'); @@ -87,8 +89,8 @@ public function enable() { /** * @return Response - * @AuthorizedAdminSetting(settings=OCA\DAV\Settings\CalDAVSettings) */ + #[AuthorizedAdminSetting(settings: CalDAVSettings::class)] public function disable() { $this->config->setAppValue($this->appName, 'generateBirthdayCalendar', 'no'); diff --git a/apps/dav/lib/Controller/DirectController.php b/apps/dav/lib/Controller/DirectController.php index 4e3e29d0e6b17..77f5b8f541900 100644 --- a/apps/dav/lib/Controller/DirectController.php +++ b/apps/dav/lib/Controller/DirectController.php @@ -11,6 +11,7 @@ use OCA\DAV\Db\Direct; use OCA\DAV\Db\DirectMapper; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSForbiddenException; @@ -69,8 +70,6 @@ public function __construct(string $appName, } /** - * @NoAdminRequired - * * Get a direct link to a file * * @param int $fileId ID of the file @@ -82,6 +81,7 @@ public function __construct(string $appName, * * 200: Direct link returned */ + #[NoAdminRequired] public function getUrl(int $fileId, int $expirationTime = 60 * 60 * 8): DataResponse { $userFolder = $this->rootFolder->getUserFolder($this->userId); diff --git a/apps/dav/lib/Controller/InvitationResponseController.php b/apps/dav/lib/Controller/InvitationResponseController.php index 4144e58d2ccc7..678d0d47b2849 100644 --- a/apps/dav/lib/Controller/InvitationResponseController.php +++ b/apps/dav/lib/Controller/InvitationResponseController.php @@ -10,7 +10,9 @@ use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\Attribute\OpenAPI; +use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IDBConnection; @@ -52,12 +54,11 @@ public function __construct(string $appName, IRequest $request, } /** - * @PublicPage - * @NoCSRFRequired - * * @param string $token * @return TemplateResponse */ + #[PublicPage] + #[NoCSRFRequired] public function accept(string $token):TemplateResponse { $row = $this->getTokenInformation($token); if (!$row) { @@ -76,12 +77,11 @@ public function accept(string $token):TemplateResponse { } /** - * @PublicPage - * @NoCSRFRequired - * * @param string $token * @return TemplateResponse */ + #[PublicPage] + #[NoCSRFRequired] public function decline(string $token):TemplateResponse { $row = $this->getTokenInformation($token); if (!$row) { @@ -101,12 +101,11 @@ public function decline(string $token):TemplateResponse { } /** - * @PublicPage - * @NoCSRFRequired - * * @param string $token * @return TemplateResponse */ + #[PublicPage] + #[NoCSRFRequired] public function options(string $token):TemplateResponse { return new TemplateResponse($this->appName, 'schedule-response-options', [ 'token' => $token @@ -114,13 +113,12 @@ public function options(string $token):TemplateResponse { } /** - * @PublicPage - * @NoCSRFRequired - * * @param string $token * * @return TemplateResponse */ + #[PublicPage] + #[NoCSRFRequired] public function processMoreOptionsResult(string $token):TemplateResponse { $partstat = $this->request->getParam('partStat');