libresign/lib/Middleware/GlobalInjectionMiddleware.php
Vitor Mattos 034ff9ecbb
fix: psalm issues about override
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-10-07 18:23:41 -03:00

27 lines
764 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Middleware;
use OCA\Files\Controller\ViewController;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
class GlobalInjectionMiddleware extends Middleware {
#[\Override]
public function afterController(Controller $controller, string $methodName, Response $response) {
if ($controller instanceof ViewController) {
$policy = new ContentSecurityPolicy();
$policy->addAllowedFrameDomain("'self'");
$response->setContentSecurityPolicy($policy);
}
return $response;
}
}