88use InvalidArgumentException ;
99use OCA \Theming \ImageManager ;
1010use OCA \Theming \Service \ThemesService ;
11+ use OCA \Theming \Settings \Admin ;
1112use OCA \Theming \ThemingDefaults ;
1213use OCP \App \IAppManager ;
1314use OCP \AppFramework \Controller ;
1415use OCP \AppFramework \Http ;
16+ use OCP \AppFramework \Http \Attribute \AuthorizedAdminSetting ;
17+ use OCP \AppFramework \Http \Attribute \BruteForceProtection ;
18+ use OCP \AppFramework \Http \Attribute \NoCSRFRequired ;
19+ use OCP \AppFramework \Http \Attribute \PublicPage ;
1520use OCP \AppFramework \Http \DataDisplayResponse ;
1621use OCP \AppFramework \Http \DataResponse ;
1722use OCP \AppFramework \Http \FileDisplayResponse ;
@@ -66,12 +71,12 @@ public function __construct(
6671 }
6772
6873 /**
69- * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
7074 * @param string $setting
7175 * @param string $value
7276 * @return DataResponse
7377 * @throws NotPermittedException
7478 */
79+ #[AuthorizedAdminSetting(settings: Admin::class)]
7580 public function updateStylesheet ($ setting , $ value ) {
7681 $ value = trim ($ value );
7782 $ error = null ;
@@ -146,12 +151,12 @@ public function updateStylesheet($setting, $value) {
146151 }
147152
148153 /**
149- * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
150154 * @param string $setting
151155 * @param mixed $value
152156 * @return DataResponse
153157 * @throws NotPermittedException
154158 */
159+ #[AuthorizedAdminSetting(settings: Admin::class)]
155160 public function updateAppMenu ($ setting , $ value ) {
156161 $ error = null ;
157162 switch ($ setting ) {
@@ -195,10 +200,10 @@ private function isValidUrl(string $url): bool {
195200 }
196201
197202 /**
198- * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
199203 * @return DataResponse
200204 * @throws NotPermittedException
201205 */
206+ #[AuthorizedAdminSetting(settings: Admin::class)]
202207 public function uploadImage (): DataResponse {
203208 $ key = $ this ->request ->getParam ('key ' );
204209 if (!in_array ($ key , self ::VALID_UPLOAD_KEYS , true )) {
@@ -275,12 +280,12 @@ public function uploadImage(): DataResponse {
275280
276281 /**
277282 * Revert setting to default value
278- * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
279283 *
280284 * @param string $setting setting which should be reverted
281285 * @return DataResponse
282286 * @throws NotPermittedException
283287 */
288+ #[AuthorizedAdminSetting(settings: Admin::class)]
284289 public function undo (string $ setting ): DataResponse {
285290 $ value = $ this ->themingDefaults ->undo ($ setting );
286291
@@ -298,11 +303,11 @@ public function undo(string $setting): DataResponse {
298303
299304 /**
300305 * Revert all theming settings to their default values
301- * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
302306 *
303307 * @return DataResponse
304308 * @throws NotPermittedException
305309 */
310+ #[AuthorizedAdminSetting(settings: Admin::class)]
306311 public function undoAll (): DataResponse {
307312 $ this ->themingDefaults ->undoAll ();
308313 $ this ->appManager ->setDefaultApps ([]);
@@ -319,8 +324,6 @@ public function undoAll(): DataResponse {
319324 }
320325
321326 /**
322- * @PublicPage
323- * @NoCSRFRequired
324327 * @NoSameSiteCookieRequired
325328 *
326329 * Get an image
@@ -333,6 +336,8 @@ public function undoAll(): DataResponse {
333336 * 200: Image returned
334337 * 404: Image not found
335338 */
339+ #[PublicPage]
340+ #[NoCSRFRequired]
336341 public function getImage (string $ key , bool $ useSvg = true ) {
337342 try {
338343 $ file = $ this ->imageManager ->getImage ($ key , $ useSvg );
@@ -356,8 +361,6 @@ public function getImage(string $key, bool $useSvg = true) {
356361 }
357362
358363 /**
359- * @NoCSRFRequired
360- * @PublicPage
361364 * @NoSameSiteCookieRequired
362365 * @NoTwoFactorRequired
363366 *
@@ -371,6 +374,8 @@ public function getImage(string $key, bool $useSvg = true) {
371374 * 200: Stylesheet returned
372375 * 404: Theme not found
373376 */
377+ #[PublicPage]
378+ #[NoCSRFRequired]
374379 public function getThemeStylesheet (string $ themeId , bool $ plain = false , bool $ withCustomCss = false ) {
375380 $ themes = $ this ->themesService ->getThemes ();
376381 if (!in_array ($ themeId , array_keys ($ themes ))) {
@@ -407,10 +412,6 @@ public function getThemeStylesheet(string $themeId, bool $plain = false, bool $w
407412 }
408413
409414 /**
410- * @NoCSRFRequired
411- * @PublicPage
412- * @BruteForceProtection(action=manifest)
413- *
414415 * Get the manifest for an app
415416 *
416417 * @param string $app ID of the app
@@ -420,6 +421,9 @@ public function getThemeStylesheet(string $themeId, bool $plain = false, bool $w
420421 * 200: Manifest returned
421422 * 404: App not found
422423 */
424+ #[PublicPage]
425+ #[NoCSRFRequired]
426+ #[BruteForceProtection('manifest ' )]
423427 public function getManifest (string $ app ): JSONResponse {
424428 $ cacheBusterValue = $ this ->config ->getAppValue ('theming ' , 'cachebuster ' , '0 ' );
425429 if ($ app === 'core ' || $ app === 'settings ' ) {
0 commit comments