Merge conflict

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

Review main Work in progress

98330[TASK] Tell whether a preview needs the backend session of the browser

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

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

  1. 98330 [TASK] Tell whether a preview needs the backend session of the browser This change

  2. 98275[BUGFIX] Simulate restricted ancestors in preview This change is based on it Matthias Vogel → main, 14.3 Hard +673 −91 CR 0 V 0 Merge conflict
  3. 98274[TASK] Find inherited page restrictions in one place This change is based on it Matthias Vogel → main, 14.3 Hard +577 −75 CR 0 V 0 1 unresolved

Issues 1

Files 12

Review log 23

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

  2. 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

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

    Topic set to cross-domain-preview