Merge conflict
Gerrit cannot merge this change. It needs a rebase onto main.
98330[TASK] Tell whether a preview needs the backend session of the browser
Commit message
This patch adds an internal API. It tells whether a preview needs the backend session of the browser. All new classes are marked @internal. The new methods are marked @internal or are part of an @internal class. No existing core code calls the API yet. The later patch "[BUGFIX] Open the backend preview page for sites without backend cookie" of #110664 uses it in `PreviewUriBuilder`. This patch needs 98275 "[BUGFIX] Simulate restricted ancestors in preview" and its base 98274 "[TASK] Find inherited page restrictions in one place". From 98274 it uses `PageAccessRestrictionResolver` and `RecordAccessRestriction`. From 98275 it uses `PageAccessRestrictionResolver::resolveRestrictionsDenyingVisitor()` and `RecordAccessVoter::getRestrictionDenyingAccess()`. Merge 98274 first, then 98275, then this patch. The "View" buttons of the backend open the address of a page. The frontend reads the backend session from the cookie of the browser and then also shows hidden and restricted pages. Where this cookie does not reach the site, the backend must know before the click whether the preview needs the backend session. The preview of #110664 needs this information. The API has these parts: - `PreviewBackendSessionRequirement` tells whether the frontend shows a preview only with the backend session: in a workspace, with a simulated date or simulated frontend user groups, for a page that a visitor does not see, below a backend user section, in a disabled language and for a hidden translation. It checks each ancestor that extends its restriction to subpages. For a record, only the hidden flag and the access time count. The frontend hides a record for frontend user groups also from a backend user, and the preview link simulates only the groups of the page. - `resolveRecordRestrictionDenyingVisitor()` of `PageAccessRestrictionResolver` returns the part of the access restriction of a record that denies access to a visitor. It uses the same context of a visitor as `resolveRestrictionsDenyingVisitor()`. - `RecordAccessRestriction::isEmpty()` tells whether a restriction has no value. - `CookieScope::reaches()` tells whether a browser sends a cookie of this scope to an address. `SetCookieService::getScope()` returns the domain and the path of its cookie. `BackendSessionCookieScope` applies it to the backend session cookie. `PreviewBackendSessionRequirement` reads the simulation parameters from the address. The caller and event listeners can also add these parameters, and `AccessRestrictionSimulator` writes the simulated date into the context. A runtime cache keeps the result for a page and a language for the request. It does not keep the result for a record. The later patch uses `PreviewBackendSessionRequirement` and `BackendSessionCookieScope` in `PreviewUriBuilder`. A "View" button then opens a preview page of the backend if the preview needs the backend session and the cookie does not reach the site. The preview links do not change.
Show more Show less
Resolves: #TBD Related: #110664 Releases: main, 14.3 Change-Id: I7deb4b0ddffac62c93a4b295ce008ffb1a282b55
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/30/98330/1 && git checkout FETCH_HEAD
- Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/30/98330/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 3
-
98330 [TASK] Tell whether a preview needs the backend session of the browser This change
- 98275[BUGFIX] Simulate restricted ancestors in preview
- 98274[TASK] Find inherited page restrictions in one place
Issues 1
Files 12
- typo3/sysext/backend/Classes/Routing/BackendSessionCookieScope.phpnew+39 −0
- typo3/sysext/backend/Classes/Routing/PreviewBackendSessionRequirement.phpnew+146 −0
- typo3/sysext/backend/Tests/Functional/Routing/Fixtures/pages_preview_backend_session.csvnew+19 −0
- typo3/sysext/backend/Tests/Functional/Routing/PreviewBackendSessionRequirementTest.phpnew+186 −0
- typo3/sysext/backend/Tests/Unit/Routing/BackendSessionCookieScopeTest.phpnew+91 −0
- typo3/sysext/core/Classes/Domain/Access/PageAccessRestrictionResolver.php+26 −7
- typo3/sysext/core/Classes/Domain/Access/RecordAccessRestriction.php+19 −0
- typo3/sysext/core/Classes/Http/CookieScope.php+57 −0
- typo3/sysext/core/Classes/Http/SetCookieService.php+10 −0
- typo3/sysext/core/Tests/Unit/Domain/Access/PageAccessRestrictionResolverTest.php+52 −10
- typo3/sysext/core/Tests/Unit/Domain/Access/RecordAccessRestrictionTest.phpnew+42 −0
- typo3/sysext/core/Tests/Unit/Http/CookieScopeTest.phpnew+55 −0
Review log 23
-
Matthias Vogel uploaded patch set 1 12/04/26, 09:03
-
core-ci voted on patch set 1 V +1 12/04/26, 10:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116314
-
Matthias Vogel wrote 12/04/26, 10:25
Topic set to cross-domain-preview