Merge conflict

Gerrit cannot merge this change. It needs a rebase onto main.

Review main Work in progress

98325[BUGFIX] Keep the preview token in links, forms and redirects

Matthias Vogel CR 0 V 0 Hard +828 −38 updated 12/04/26, 10:25

Commit message

A page in the preview frame of the backend loses the preview token when
the backend user follows a link, sends a form or gets a redirect. The
next page then shows without the preview, for example without the
workspace of the token.

The new class PreviewTokenKeeper adds the token of the request to an
address that leads to a host of the preview (PreviewHosts::allowsUrl()).
It removes a token from every other address. QueryParameterReplacer
keeps every other byte of the address, because signed addresses of
login or payment services compare them. PreviewTokenAuthenticator now
gives the hosts of the token to the other middlewares in the new
request attribute PreviewHosts::REQUEST_ATTRIBUTE. Thus the site
resolves the hosts once for each request. These places use the class:

- KeepPreviewTokenInLinksEventListener changes the links to pages and
  to web addresses (AfterLinkIsGeneratedEvent). A page of the type
  "Link to external URL" gives a link of the type "url". Links to
  files, mail addresses and phone numbers stay as they are.
- FormViewHelper adds the token to the action of a form sent via POST.
  A form sent via GET gets the token in a hidden field, because the
  browser replaces the query of the action. A form with the target
  "_top" or "_parent" gets the target "_self" in the preview, so the
  page does not replace the backend. FormViewHelper gets the class
  through an inject method, as its other services. Extensions extend
  FormViewHelper, and a new constructor argument breaks a subclass
  with its own constructor.
- PreviewTokenAuthenticator changes the Location header of each
  redirect in the preview: shortcut pages, redirect records and
  redirects of extensions. Until now it only removed the token from a
  redirect outside the preview.

RedirectHandler ignores the token when it selects a redirect record
and when it compares the target with the address of the request.
Without this, a redirect record that respects the query parameters
does not match in the preview. A redirect record to its own address
then also redirects again and again, because the preview adds the
token to the target.

These cases get no token:

- An address on plain HTTP to a host whose sites use HTTPS only. The
  browser sends the query in the clear before the site redirects.
- An address with user information, another scheme or a host outside
  the preview.

A relative address stays relative. A fragment stays after the token.
Navigations that scripts of the page start keep the token in the
later patch "Keep the preview token in navigations that scripts
start".

This patch updates the changelog entry of "Preview hidden pages across
site domains". It adds the section "Links, redirects and forms". The
line that links, forms and redirects do not keep the token yet now
names only the navigations that scripts start.

This patch needs "[BUGFIX] Preview hidden pages across site domains"
(change 97235), which contains "[TASK] Accept preview tokens in the
frontend". It is chained on top of "[BUGFIX] Renew the preview token
of the frame" and does not use code of that patch. Merge the patches
below it in the chain first, then this patch.
Show more Show less
Resolves: #TBD
Related: #110664
Releases: main, 14.3
Change-Id: If79a44d5599ccd5495987e60fd4986e51256c8ad

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 1
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/25/98325/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/25/98325/1 && 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 16

  1. 98329[BUGFIX] Use preview tokens in the frames of the workspace preview Based on this change Matthias Vogel → main, 14.3 Hard +580 −55 CR 0 V 0 Work in progress Merge conflict
  2. 98328[TASK] Add a live view kind of preview token Based on this change Matthias Vogel → main, 14.3 Hard +771 −73 CR 0 V 0 Work in progress Merge conflict
  3. 98327[BUGFIX] Follow the page of the preview frame in the backend Based on this change Matthias Vogel → main, 14.3 Expert +1225 −114 CR 0 V -1 Work in progress Merge conflict
  4. 98326[BUGFIX] Keep the preview token in navigations that scripts start Based on this change Matthias Vogel → main, 14.3 Hard +922 −4 CR 0 V 0 Work in progress Merge conflict
  5. 98325 [BUGFIX] Keep the preview token in links, forms and redirects This change

  6. 98324[BUGFIX] Renew the preview token of the frame This change is based on it Matthias Vogel → main, 14.3 Expert +1634 −63 CR 0 V 0 Work in progress Merge conflict
  7. 98323[TASK] Add one frame component for the preview frames of the backend This change is based on it Matthias Vogel → main, 14.3 Hard +544 −68 CR 0 V 0 Work in progress Merge conflict
  8. 97235[BUGFIX] Preview hidden pages across site domains This change is based on it Matthias Vogel → main, 14.3 Hard +467 −10 CR 0 V 0 Work in progress Merge conflict 19 unresolved
  9. 98322[TASK] Accept preview tokens in the frontend This change is based on it Matthias Vogel → main, 14.3 Expert +1994 −4 CR 0 V 0 Work in progress Merge conflict
  10. 98321[TASK] Issue preview tokens in the backend This change is based on it Matthias Vogel → main, 14.3 Hard +880 −1 CR 0 V 0 Work in progress Merge conflict
  11. 98320[TASK] Check where a request with a preview token comes from This change is based on it Matthias Vogel → main, 14.3 Hard +934 −1 CR 0 V 0 Work in progress Merge conflict
  12. 98319[BUGFIX] Handle query parameters of links in one place This change is based on it Matthias Vogel → main, 14.3 Hard +435 −20 CR 0 V 0 Work in progress
  13. 98318[TASK] Resolve the sites and hosts a backend user may preview This change is based on it Matthias Vogel → main, 14.3 Hard +700 −0 CR 0 V 0 Work in progress
  14. 98317[TASK] Sign and verify preview tokens This change is based on it Matthias Vogel → main, 14.3 Hard +625 −0 CR 0 V -1 Work in progress Merge conflict
  15. 98316[TASK] Add typed claims for preview tokens This change is based on it Matthias Vogel → main, 14.3 Hard +530 −0 CR 0 V -1 Work in progress
  16. 98315[TASK] Add a read-only backend user for one workspace This change is based on it Matthias Vogel → main, 14.3 Expert +1719 −2 CR 0 V 0 Work in progress

    The chain has patch set 1 of 2, the changes above it need a rebase.

Issues 1

Files 14

Review log 23

  1. Matthias Vogel uploaded patch set 1 12/04/26, 09:02

  2. core-ci voted on patch set 1 V +1 12/04/26, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116309

  3. Matthias Vogel wrote 12/04/26, 10:25

    Topic set to cross-domain-preview