--- /dev/null
+<?php
+
+namespace wcf\http\middleware;
+
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\MiddlewareInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+use wcf\http\LegacyPlaceholderResponse;
+
+/**
+ * Adds 'x-frame-options: SAMEORIGIN' to the response.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2022 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Http\Middleware
+ * @since 5.6
+ */
+final class EnforceFrameOptions implements MiddlewareInterface
+{
+ /**
+ * @inheritDoc
+ */
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
+ {
+ $response = $handler->handle($request);
+
+ if ($response instanceof LegacyPlaceholderResponse) {
+ return $response;
+ }
+
+ return $response->withHeader('x-frame-options', 'SAMEORIGIN');
+ }
+}
use Psr\Http\Message\ResponseInterface;
use wcf\http\LegacyPlaceholderResponse;
use wcf\http\middleware\EnforceCacheControlPrivate;
+use wcf\http\middleware\EnforceFrameOptions;
use wcf\http\Pipeline;
use wcf\system\application\ApplicationHandler;
use wcf\system\box\BoxHandler;
$pipeline = new Pipeline([
new EnforceCacheControlPrivate(),
+ new EnforceFrameOptions(),
]);
$this->sendPsr7Response(
return;
}
- $response->withHeader('x-frame-options', 'SAMEORIGIN');
-
$emitter = new SapiEmitter();
$emitter->emit($response);
}