Review main Ready for review

97235[BUGFIX] Preview hidden pages across site domains

Matthias Vogel CR 0 V 0 Impossible +10762 −91 updated 11/19/26, 12:30

Commit message

Editors could only preview unpublished pages on domains where they were
logged in to the backend. A shared cookie domain was the only way
around it, and it exposes the backend session to every host of that
domain.

Where the backend login cookie does not reach the site and the page
needs the backend login to be shown as a preview, the View button and
the other preview links now open a backend page that shows the site in
a frame with a short-lived preview token. Everywhere else they open the
page directly, as before. The Preview module and the workspace preview
always load their frames with a token.

PreviewTokenService signs and verifies the token. In the backend,
PreviewTokenIssuer signs it after checking the rights of the editor,
with the simulation of the page, and renews it only for the editor who
opened the preview, in the workspace of the token. In the frontend,
PreviewTokenAuthenticator verifies it, checks the host, the site and
the language and makes the editor a stateless backend user of the
request, without session or cookie. Once the page is resolved,
PreviewSimulator lets PreviewPageAccess check the permission to show it
and filter the simulated frontend user groups. Links, redirects, forms
rendered with f:form and a small navigation script
(PreviewNavigationScript) carry the token.

The token names no hosts: for a token of an editor the site resolves
the hosts of the preview from the rights of the editor on every
request. It is accepted only for the page in the frame and the requests
this page sends to its own origin, and the backend user of a preview
may not change any record. The live frame of the workspace preview gets
a visitor token, which shows the page as a visitor sees it. A visitor
token is valid on every site of the installation, and the site loads no
editor for it.

The token goes only to the hosts of the preview: not to a plain HTTP
address of a host whose sites run on HTTPS only, and not to an address
a browser reads differently than it is written. Only the token is added
or removed. The rest of an address keeps its bytes. A window or tab
opened with a token is redirected to the address it requested without
it. Responses with a token are never cached, the token is never part of
the cHash, and only the backend and the site itself may frame them. The
navigation script runs under the Content-Security-Policy of the site,
and the admin panel in the frame stores its settings through the
backend page around it.

PreviewUriBuilder::buildUri() still returns the address on the site.
The new internal buildBackendPreviewUri() returns the preview page
where a token is needed, and buildBackendPreviewUriFor() does the same
for an address that is already built.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 12
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/35/97235/12 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/35/97235/12 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Relation chain 3

  1. main 96718[WIP] Add device preview with zoom and pan to the preview module Based on this change Work in progress Merge conflict Benjamin Kott CR 0 V 0 Nightmare +5791 −649
  2. main 97236[FEATURE] Compare every preview with the live page Based on this change Work in progress Merge conflict Matthias Vogel CR 0 V 0 Expert +1248 −698
  3. 97235 [BUGFIX] Preview hidden pages across site domains This change

Merge conflicts 60

Issues 1

Files 83

Show 63 more files

Review log 1833

Show 58 earlier messages
  1. Matthias Vogel uploaded patch set 1 10/30/26, 10:54

  2. core-ci voted on patch set 1 V -1 10/30/26, 11:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112855

  3. Matthias Vogel uploaded patch set 2 V -1 10/30/26, 14:19

  4. core-ci voted on patch set 2 V +1 10/30/26, 14:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112879

  5. Oli Bartsch commented on patch set 2 10/31/26, 09:04

    I would like to talk about this, to prevent introducing multiple different token solutions now. Check e.g. https://review.typo3.org/c/Packages/TYPO3.CMS/+/96561.
  6. Oli Bartsch commented on patch set 2 11/06/26, 08:24

    Reply

    still open
  7. Matthias Vogel uploaded patch set 3 V +1 11/09/26, 16:51

  8. core-ci voted on patch set 3 V +1 11/09/26, 17:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113740

  1. Matthias Vogel commented on patch set 3 11/10/26, 08:22

    Reply

    We discussed this, and the two concepts of tokens are different enough.
  2. Matthias Vogel uploaded patch set 4 V +1 11/10/26, 10:22

  3. core-ci voted on patch set 4 V +1 11/10/26, 10:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113871

  4. Matthias Vogel uploaded patch set 5 V +1 11/11/26, 17:52

  5. core-ci voted on patch set 5 V -1 11/11/26, 18:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114134

  6. core-ci commented on patch set 5 11/12/26, 09:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114134

  7. Matthias Vogel uploaded patch set 6 V -1 11/12/26, 13:29

  8. core-ci voted on patch set 6 V +1 11/12/26, 13:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114187

  9. Matthias Vogel uploaded patch set 7 V +1 11/12/26, 16:44

  10. core-ci voted on patch set 7 V +1 11/12/26, 16:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114201

  11. Matthias Vogel uploaded patch set 8 V +1 11/17/26, 13:55

  12. Matthias Vogel commented on patch set 8 11/17/26, 13:55

    Reading order for this change (patch set 8) 1. The token: PreviewTokenService signs and verifies it; PreviewToken and PreviewProfile are what it carries; PreviewHosts and PreviewHostsResolver resolve the hosts of the editor on every request (EXT:core, Classes/Preview). 2. The backend issues it: PreviewTokenIssuer, the preview page (EXT:backend PreviewPageController with the routes preview and preview_token), and PreviewUriBuilder::buildBackendPreviewUri() / buildBackendPreviewUriFor(), used by View, the Preview module and the workspace preview. 3. The frontend checks it: PreviewTokenAuthenticator (verify, authorize, applyProfile, respond; PreviewRequestKind names the kind of request), PreviewBackendUserInitializer and PreviewBackendUserAuthentication (the stateless editor), and PreviewSimulator, which calls PreviewPageAccess (page rights, groups) and PreviewNavigationScript (the navigation script). 4. The token travels: PageLinkBuilder, f:form (FormViewHelper), redirects (PreviewTokenAuthenticator::withTokenInLocation(), RedirectHandler), and the cHash exclusion. 5. The scripts: preview-frame.ts (backend page around the frame) and preview-navigation.ts (site); Playwright specs in Build/tests/playwright/e2e/preview. 6. The changelog entry Important-110664 says what extension authors and administrators have to check.
  13. core-ci voted on patch set 8 V +1 11/17/26, 14:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114739

  14. Matthias Vogel uploaded patch set 9 V +1 11/18/26, 09:16

  15. core-ci voted on patch set 9 V +1 11/18/26, 10:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114837

  16. Matthias Vogel uploaded patch set 10 V +1 11/18/26, 10:52

  17. core-ci voted on patch set 10 V -1 11/18/26, 11:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114854

  18. core-ci commented on patch set 10 11/18/26, 12:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114854

  19. core-ci voted on patch set 10 V +1 11/18/26, 12:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114854

  20. Matthias Vogel uploaded patch set 11 V +1 11/18/26, 12:52

  21. core-ci voted on patch set 11 V +1 11/18/26, 13:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114876

  22. Matthias Vogel marked it ready for review 11/18/26, 15:02

  23. Matthias Vogel uploaded patch set 12 V +1 11/19/26, 09:38

  24. core-ci voted on patch set 12 V +1 11/19/26, 09:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/114988

  25. Matthias Vogel marked it ready for review 11/19/26, 12:30