98315[TASK] Add a read-only backend user for one workspace
Commit message
This patch adds an internal API: a backend user that only reads data
and that stays in one workspace. All new classes are marked @internal.
No core code creates the new backend user yet. Two later patches
for #110664 use it:
- "Accept preview tokens in the frontend" makes the new user the
backend user of a frontend request with a preview token.
- "Use preview tokens in the frames of the workspace preview" uses
the new user to find the hosts of the workspace preview in another
workspace.
A preview must show pages with the rights of a backend user, but it
must never change data. The core has no backend user for this.
PreviewUserAuthentication of EXT:workspaces has no user record and
shows every page of the workspace.
The new class ReadOnlyBackendUserAuthentication gets two values in
its constructor:
- $lockedWorkspace: the ID of the one workspace that the user can
use. 0 is the live workspace.
- $originalUserIdInSwitchUserMode: the ID of the original user of
the "switch user" mode, or null.
initializeFromRecord() then takes the user record. The user keeps
the rights of the user record and its groups, with these limits:
- It has no right to change tables, pages or records, also as an
admin. check('tables_modify'), doesUserHaveAccess(), calcPerms(),
getPagePermsClause() and checkRecordEditAccess() deny each change.
ReadOnlyBackendUserDataHandlerGuard stops process_datamap() and
process_cmdmap() for this user.
- It changes no files. It keeps only the permissions to read files
and folders. The storages of FAL do not check these permissions in
a frontend request or for an admin. Thus the new
ReadOnlyBackendUserFileGuard stops each change of a file or a
folder through a storage. The processing folders stay writable for
processed images.
- It stays in $lockedWorkspace. initializeFromRecord() throws an
exception when the groups of the user do not grant access to this
workspace, also when it is the live workspace. After the
exception, the object has no user record and no groups.
The user cannot change to another workspace later:
setTemporaryWorkspace() refuses each other workspace, also for the
keyword "ADMCMD_prev=LIVE" of WorkspacePreview. The DataHandler
and EXT:workspaces write the property $workspace directly. A
property hook refuses each other value with an exception.
- It has no session and no cookie, and it does not log in.
createUserSession() and initializeBackendLogin() throw an
exception. handleUserLoggedIn() does nothing.
- It writes nothing to the user record. It keeps no password, no MFA
data and no token for a password reset.
- It takes only one user record. A second call of
initializeFromRecord() and each call of setBeUserByUid() throw an
exception.
- It gives no right to flush all caches. The DataHandler still lets
an admin flush the "pages" group of caches, because it asks only
isAdmin() for this right.
- The ID of the original user of the "switch user" mode comes from
the constructor. Thus isSystemMaintainer() and the system log keep
the limits of this mode. Session data cannot change it.
- Each entry of the user in the system log names the locked
workspace.
The class does not do these things. The caller does them:
- It checks that the user can log in: the record comes from
getRawUserByUid(), and the caller checks BE/adminOnly,
isUserAllowedToLogin(), BE/IPmaskList and BE/lockSSL.
- It checks the right to show a page with doesUserHaveAccess(). The
frontend does not ask this user for the right to show a page or a
record.
- It builds a new object for each request. Thus a change of the user
record, its groups or its workspace has an effect on the next
request.
- It never makes this user the backend user of a backend request.
The controllers of the backend write data for the backend user of
the request, for example the locks of records.
The security voters decide about the principal of this user with the
full rights of its groups. In the core, only BackendUserAuthentication
asks them for a write scope.
The class extends BackendUserAuthentication and not
FrontendBackendUserAuthentication, as PreviewUserAuthentication of
EXT:workspaces does. Thus the admin panel is not available for this
user. PageInformationFactory now accepts each backend user for the
doktype "Backend User Section".
The property hook needs PHP 8.4. The 14.3 branch supports PHP 8.2.
Thus the backport to 14.3 has no hook on the property $workspace.
There, ReadOnlyBackendUserDataHandlerGuard checks the workspace of
the user, and setWorkspace() and setTemporaryWorkspace() refuse each
other workspace as on main. The test
readOnlyBackendUserRefusesADirectChangeOfItsWorkspace changes in the
backport: it checks the guard and not the property.
Show more Show less
Resolves: #111720 Related: #110664 Related: #111699 Releases: main, 14.3 Change-Id: I0f93604ef06ad826b304cf1bbdc2023112796fc2
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 2
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/15/98315/2 && git checkout FETCH_HEAD
- Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/15/98315/2 && 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
- 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 This change
Merge conflicts 2
Issues 3
Files 17
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserAlreadyInitializedException.phpnew+26 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserAuthentication.phpnew+384 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserChangeDeniedException.phpnew+26 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserDataHandlerGuard.phpnew+67 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserFileGuard.phpnew+180 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserLoginDeniedException.phpnew+26 −0
- typo3/sysext/frontend/Classes/Authentication/ReadOnlyBackendUserWorkspaceDeniedException.phpnew+26 −0
- typo3/sysext/frontend/Classes/Page/PageInformationFactory.php+2 −2
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/Extensions/test_read_only_backend_user/Configuration/RequestMiddlewares.phpnew+16 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/Extensions/test_read_only_backend_user/composer.jsonnew+18 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/ReadOnlyBackendUserMiddleware.phpnew+54 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/read_only_backend_user.csvnew+19 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/read_only_backend_user_frontend.csvnew+4 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/read_only_backend_user_frontend.typoscriptnew+5 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/Fixtures/read_only_backend_user_version_in_other_workspace.csvnew+3 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/ReadOnlyBackendUserAuthenticationTest.phpnew+859 −0
- typo3/sysext/frontend/ext_localconf.php+4 −0
Review log 35
-
Matthias Vogel uploaded patch set 1 12/04/26, 08:28
-
core-ci voted on patch set 1 V +1 12/04/26, 08:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116295
-
Matthias Vogel updated the commit message in patch set 2
V +112/04/26, 09:32 -
core-ci voted on patch set 2 V +1 12/04/26, 10:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/116328
-
Matthias Vogel wrote 12/04/26, 10:25
Topic set to cross-domain-preview