Merge conflict
Gerrit cannot merge this change. It needs a rebase onto main.
98320[TASK] Check where a request with a preview token comes from
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
- 98329[BUGFIX] Use preview tokens in the frames of the workspace preview
- 98328[TASK] Add a live view kind of preview token
- 98327[BUGFIX] Follow the page of the preview frame in the backend
- 98326[BUGFIX] Keep the preview token in navigations that scripts start
- 98325[BUGFIX] Keep the preview token in links, forms and redirects
- 98324[BUGFIX] Renew the preview token of the frame
- 98323[TASK] Add one frame component for the preview frames of the backend
- 97235[BUGFIX] Preview hidden pages across site domains
- 98322[TASK] Accept preview tokens in the frontend
- 98321[TASK] Issue preview tokens in the backend
-
98320 [TASK] Check where a request with a preview token comes from This change
- 98319[BUGFIX] Handle query parameters of links in one place
- 98318[TASK] Resolve the sites and hosts a backend user may preview
- 98317[TASK] Sign and verify preview tokens
- 98316[TASK] Add typed claims for preview tokens
-
98315[TASK] Add a read-only backend user for one workspace
The chain has patch set 1 of 2, the changes above it need a rebase.
Issues 1
Files 16
- typo3/sysext/core/Classes/Preview/PreviewDenialReason.php+17 −1
- typo3/sysext/frontend/Classes/Preview/Rule/ActiveBackendSessionRule.phpnew+56 −0
- typo3/sysext/frontend/Classes/Preview/Rule/HostOfPreviewRule.phpnew+44 −0
- typo3/sysext/frontend/Classes/Preview/Rule/RequestFromFrameRule.phpnew+61 −0
- typo3/sysext/frontend/Classes/Preview/Rule/SiteOfPreviewRule.phpnew+49 −0
- typo3/sysext/frontend/Classes/Preview/PreviewRequest.phpnew+39 −0
- typo3/sysext/frontend/Classes/Preview/PreviewRequestCheck.phpnew+61 −0
- typo3/sysext/frontend/Classes/Preview/PreviewRequestKind.phpnew+58 −0
- typo3/sysext/frontend/Classes/Preview/PreviewRequestKindResolver.phpnew+53 −0
- typo3/sysext/frontend/Classes/Preview/PreviewRequestRuleInterface.phpnew+36 −0
- typo3/sysext/frontend/Tests/Functional/Preview/Rule/ActiveBackendSessionRuleTest.phpnew+104 −0
- typo3/sysext/frontend/Tests/Unit/Preview/Rule/HostOfPreviewRuleTest.phpnew+65 −0
- typo3/sysext/frontend/Tests/Unit/Preview/Rule/RequestFromFrameRuleTest.phpnew+82 −0
- typo3/sysext/frontend/Tests/Unit/Preview/Rule/SiteOfPreviewRuleTest.phpnew+76 −0
- typo3/sysext/frontend/Tests/Unit/Preview/PreviewRequestCheckTest.phpnew+79 −0
- typo3/sysext/frontend/Tests/Unit/Preview/PreviewRequestKindResolverTest.phpnew+54 −0
Review log 23
-
Matthias Vogel uploaded patch set 1 12/04/26, 09:02
-
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
-
Matthias Vogel wrote 12/04/26, 10:25
Topic set to cross-domain-preview