--- /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\system\exception\IllegalLinkException;
+use wcf\system\request\RequestHandler;
+use wcf\system\WCF;
+
+/**
+ * Restricts access to certain ACP pages for non-owners.
+ *
+ * @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 CheckForEnterpriseNonOwnerAccess implements MiddlewareInterface
+{
+ /**
+ * @inheritDoc
+ */
+ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
+ {
+ $requestHandler = RequestHandler::getInstance();
+
+ if (
+ $requestHandler->isACPRequest()
+ && \ENABLE_ENTERPRISE_MODE
+ && \defined($requestHandler->getActiveRequest()->getClassName() . '::BLACKLISTED_IN_ENTERPRISE_MODE')
+ && \constant($requestHandler->getActiveRequest()->getClassName() . '::BLACKLISTED_IN_ENTERPRISE_MODE')
+ && !WCF::getUser()->hasOwnerAccess()
+ ) {
+ throw new IllegalLinkException();
+ }
+
+ return $handler->handle($request);
+ }
+}
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use wcf\http\LegacyPlaceholderResponse;
use wcf\http\middleware\AddAcpSecurityHeaders;
+use wcf\http\middleware\CheckForEnterpriseNonOwnerAccess;
use wcf\http\middleware\CheckForExpiredAppEvaluation;
use wcf\http\middleware\CheckForOfflineMode;
use wcf\http\middleware\EnforceCacheControlPrivate;
// build request
$this->buildRequest($application);
- // enforce that certain ACP pages are not available for non-owners in enterprise mode
- if (
- $this->isACPRequest()
- && ENABLE_ENTERPRISE_MODE
- && \defined($this->getActiveRequest()->getClassName() . '::BLACKLISTED_IN_ENTERPRISE_MODE')
- && \constant($this->getActiveRequest()->getClassName() . '::BLACKLISTED_IN_ENTERPRISE_MODE')
- && !WCF::getUser()->hasOwnerAccess()
- ) {
- throw new IllegalLinkException();
- }
-
$pipeline = new Pipeline([
new AddAcpSecurityHeaders(),
new EnforceCacheControlPrivate(),
new EnforceFrameOptions(),
+ new CheckForEnterpriseNonOwnerAccess(),
new CheckForExpiredAppEvaluation(),
new CheckForOfflineMode(),
]);