Merge conflict

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

Review main Work in progress

98320[TASK] Check where a request with a preview token comes from

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

Commit message

This patch adds an internal API: rules that check a request with a
verified preview token, and one class that asks these rules. The
classes are marked @internal. No code in the core uses them yet. The
later patch "Accept preview tokens in the frontend" of #110664 uses
them. Its middleware resolves the kind of the request with
PreviewRequestKindResolver, builds a PreviewRequest and asks
PreviewRequestCheck. It denies the request with the reason of the
first rule that denies it.

A preview token is valid only in the preview frame of the backend
that issued it. A valid signature does not prove this. The site must
also check where the request comes from, the host and the site of the
request, and that the backend session of the token is still active.
Each of these conditions is one rule. Thus a reviewer can check each
rule alone.

PreviewRequestCheck asks the rules in this order. The first rule that
denies the request gives the PreviewDecision:

1. RequestFromFrameRule (priority 40): the request comes from the
   preview frame or from the page in it. Browsers tell this in the
   Fetch Metadata headers. Browsers send these headers on HTTPS. Thus
   the rule allows a request without them only on a site on plain
   HTTP. Reason: NotInFrame.
2. ActiveBackendSessionRule (30): the backend session of the token is
   stored, it is not expired, and it belongs to the backend user of
   the token. Thus the site revokes a token when the backend user
   logs out. Reason: UserNotAvailable.
3. HostOfPreviewRule (20): PreviewHosts::includesHostOf() includes
   the host of the request. Reason: Invalid, as for a token that the
   site cannot verify. The backend did not open a preview on this
   host. Thus the site must not trust the backend that the token
   names.
4. SiteOfPreviewRule (10): PreviewHosts::includesSite() includes the
   site of the request. Several sites can use one host with different
   paths. Reason: OutOfScope.

PreviewRequestKind tells the kind of a request: a window, the frame,
a request of the page, a request from elsewhere, or unknown without
Fetch Metadata. PreviewRequestKindResolver resolves the kind once for
each request. The middleware of the later patch also uses the kind:
it sends a window to the address without the token.

The rules do not check the rights of the backend user: page,
language, workspace and backend access. The core APIs for backend
users check them. "Accept preview tokens in the frontend" calls these
APIs. It also checks [BE][lockSSL] once, with the other conditions
for the login of the backend user.

The rules use the own interface PreviewRequestRuleInterface, not the
security voters of change 98203 "Decide backend access with security
voters". TYPO3 14.3 has no infrastructure for security voters, and
this series goes to main and 14.3. Thus the code stays the same on
both branches. The interface is not called "voter", so that nobody
takes it for a security voter. Each rule returns a PreviewDecision
with the reason of a denial, like BackendAccessDecision of change
98018.

The patch adds the reasons NotInFrame, OutOfScope and
UserNotAvailable to PreviewDenialReason.

This patch needs "Add typed claims for preview tokens" (PreviewToken,
PreviewDecision, PreviewDenialReason) and "Resolve the sites and
hosts a backend user may preview" (PreviewHosts). It is chained on
top of "Handle query parameters of links in one place". 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: I3fb195677945a8d9d418ea7a49964eb5abdd568d

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/20/98320/1 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/20/98320/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 Based on this change Matthias Vogel → main, 14.3 Hard +828 −38 CR 0 V 0 Work in progress Merge conflict
  6. 98324[BUGFIX] Renew the preview token of the frame Based on this change 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 Based on this change 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 Based on this change 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 Based on this change 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 Based on this change 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

  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 16

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, 10:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116307

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

    Topic set to cross-domain-preview