Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Register workspace preview middleware earlier
The current workspace preview middleware runs at a point after the Page ID (and PageArguments) has been resolved by the URL already. This means a workspace preview with a preview user (and not a backend user) does not work, as the user is registered too late in the Middleware workflow. In order to restore the functionality, the preview user is now created BEFORE the PageResolver middleware, and does everything (incl. sending the preview cookie, which is now attached to the response, and not done during processing of the request). However, as the webmount of the current page ID needs to be registered, a second middleware is added which runs before TSFE->determineId() but after the PageResolver and PageArgumentValidator middlewares. Resolves: #91662 Releases: master, 10.4 Change-Id: Ic0108d2cd468f3ecf84e5a0e06c0fd5329046606 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64900 Tested-by: Oliver Hader <oliver.hader@typo3.org> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: David Steeb <david.steeb@b13.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Hader <oliver.hader@typo3.org> Reviewed-by: David Steeb <david.steeb@b13.com> Reviewed-by: Benni Mack <benni@typo3.org>
- Loading branch information
Showing
3 changed files
with
124 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
typo3/sysext/workspaces/Classes/Middleware/WorkspacePreviewPermissions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Workspaces\Middleware; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use TYPO3\CMS\Core\Routing\PageArguments; | ||
use TYPO3\CMS\Workspaces\Authentication\PreviewUserAuthentication; | ||
|
||
/** | ||
* Middleware to set the current page ID (for accessing the page) for the PreviewBackendUser, | ||
* so the preview user is allowed to actually access the page (even if it is hidden). | ||
* | ||
* @internal | ||
*/ | ||
class WorkspacePreviewPermissions implements MiddlewareInterface | ||
{ | ||
/** | ||
* @param ServerRequestInterface $request | ||
* @param RequestHandlerInterface $handler | ||
* @return ResponseInterface | ||
* @throws \Exception | ||
*/ | ||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface | ||
{ | ||
$pageArguments = $request->getAttribute('routing', null); | ||
if ($pageArguments instanceof PageArguments && $GLOBALS['BE_USER'] instanceof PreviewUserAuthentication) { | ||
$GLOBALS['BE_USER']->setWebmounts([$pageArguments->getPageId()]); | ||
} | ||
return $handler->handle($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters