Merge conflict
Gerrit cannot merge this change. It needs a rebase onto main.
98324[BUGFIX] Renew the preview token of the frame
Commit message
A preview token is valid for 15 minutes. The module "Content > Preview" loads its frame with a token. When the frame loads a page with an expired token, the site shows its denial page and the preview stops. This happens, for example, when the browser loads a page of the frame again through its history. The backend user must then load the whole module again. This change lets the frame get a fresh token from the backend: * The denial page of the site tells the backend of the token the address and the reason of the denial, through postMessage() to the origin of the backend. A token that is not valid names no backend, so its denial page has no message. * The TypeScript module PreviewFrame listens for this message in a frame with a preview token. It accepts the message only from the page in the frame and only from a host of the preview. It posts the previous token, the address and the page to the new AJAX route "preview_token" and loads the address with the fresh token. It does this once for each address and reason. Thus a token that the site keeps denying does not cause a loop. * The new PreviewTokenController answers with the settings of the frame for the fresh token. The answer has the shape of PreviewFrameSettings, so the frame reads both with one interface. * PreviewTokenIssuer::renew() reads the previous token with PreviewTokenService::readForRenewal(), also after its expiry. Two new renewal rules deny a token of another backend user and a token of another workspace than the current one. Then the rules of the issue check the rights and the hosts again, as for a new token. The fresh token keeps the workspace and the date of the previous token and contains the current backend session. A denial throws the new PreviewTokenRenewalDeniedException. * The fresh token simulates no frontend login and no frontend user groups. The frame chooses the page and the address of the renewal, and groups can be valid only for the page of the previous token. Tokens of the backend have no groups yet, so nothing changes now. * PreviewFrameFactory::create() gets the issued preview as an optional argument. With it, the settings contain the address that renews the token, the page and the hosts of the preview, and `frame-src` allows the origins of all hosts. ViewModuleController uses this branch instead of its own code for `frame-src`. PreviewHosts::getHosts() becomes public for the hosts in the settings. * The browser loads the frame of the module without a Referer header, because the address of the module contains the token of the backend route. The changelog entry of #110664 gets sections about the renewal and about the template of the module. This change needs "Preview hidden pages across site domains" and "Add one frame component for the preview frames of the backend". It is chained on top of "Add one frame component for the preview frames of the backend". Merge the patches below it in the chain first, then this change. "Apply the date and the frontend groups of a preview token" adds groups to the token. Only when it is merged after this change, it must filter the groups again in renew() for the page of the renewal. The order of the two changes does not matter for security.
Show more Show less
Resolves: #TBD Related: #110664 Releases: main, 14.3 Change-Id: Ieb69003df014e8dab82033a72588f21a05d69adf
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/24/98324/1 && git checkout FETCH_HEAD
- Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/24/98324/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 This change
- 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
- 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 32
- Build/Sources/TypeScript/backend/preview/preview-frame.ts+87 −2
- Build/Sources/TypeScript/backend/tests/preview/preview-frame-test.ts+149 −7
- Build/tests/playwright/e2e/preview/preview-frame.spec.tsnew+105 −0
- typo3/sysext/backend/Classes/Controller/PreviewTokenController.phpnew+103 −0
- typo3/sysext/backend/Classes/Preview/Rule/BackendUserOfTokenRule.phpnew+42 −0
- typo3/sysext/backend/Classes/Preview/Rule/PreviewTokenRenewalRuleInterface.phpnew+37 −0
- typo3/sysext/backend/Classes/Preview/Rule/PreviewTokenRenewalSubject.phpnew+36 −0
- typo3/sysext/backend/Classes/Preview/Rule/WorkspaceOfTokenRule.phpnew+42 −0
- typo3/sysext/backend/Classes/Preview/IssuedPreview.php+4 −2
- typo3/sysext/backend/Classes/Preview/PreviewFrameFactory.php+30 −4
- typo3/sysext/backend/Classes/Preview/PreviewFrameSettings.php+14 −2
- typo3/sysext/backend/Classes/Preview/PreviewTokenIssuer.php+69 −3
- typo3/sysext/backend/Classes/Preview/PreviewTokenRenewalDeniedException.phpnew+40 −0
- typo3/sysext/backend/Configuration/Backend/AjaxRoutes.php+7 −0
- typo3/sysext/backend/Resources/Public/JavaScript/preview/preview-frame.js+1 −1
- typo3/sysext/backend/Tests/Functional/Controller/PreviewTokenControllerTest.phpnew+172 −0
- typo3/sysext/backend/Tests/Functional/Preview/PreviewTokenIssuerTest.php+161 −0
- typo3/sysext/backend/Tests/Unit/Preview/PreviewFrameFactoryTest.php+65 −5
- typo3/sysext/core/Classes/Preview/PreviewDenialReason.php+11 −0
- typo3/sysext/core/Classes/Preview/PreviewHosts.php+11 −0
- typo3/sysext/core/Classes/Preview/PreviewTokenService.php+22 −0
- typo3/sysext/core/Documentation/Changelog/14.3.x/Important-110664-PreviewModuleShowsHiddenPagesOnEveryDomain.rst+42 −1
- typo3/sysext/core/Tests/Functional/Preview/PreviewHostsResolverTest.php+4 −0
- typo3/sysext/core/Tests/Unit/Preview/PreviewHostsTest.php+2 −1
- typo3/sysext/core/Tests/Unit/Preview/PreviewTokenServiceTest.php+39 −0
- typo3/sysext/frontend/Classes/Middleware/PreviewTokenAuthenticator.php+23 −1
- typo3/sysext/frontend/Tests/Functional/Middleware/PreviewTokenAuthenticatorCacheHashTest.php+30 −0
- typo3/sysext/frontend/Tests/Functional/Middleware/PreviewTokenAuthenticatorContentSecurityPolicyTest.phpnew+212 −0
- typo3/sysext/frontend/Tests/Functional/Middleware/PreviewTokenAuthenticatorTest.php+15 −2
- typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php+2 −13
- typo3/sysext/viewpage/Resources/Private/Templates/Show.fluid.html+1 −1
- typo3/sysext/viewpage/Tests/Functional/Controller/ViewModuleControllerTest.php+56 −18
Show 12 more files Show less
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, 09:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116306
-
Matthias Vogel wrote 12/04/26, 10:25
Topic set to cross-domain-preview