Deprecation: #111236 - Module access gates
See forge#111236
Description
The access to backend modules is decided by security voters, see Feature: #111236 - Security voters for authorization decisions. The module access gates introduced with TYPO3 v14.2 are therefore deprecated and will be removed in TYPO3 v16.0:
\TYPO3\CMS\ Core\ Attribute\ As Module Access Gate \TYPO3\CMS\ Backend\ Module\ Module Access Gate Interface \TYPO3\CMS\ Backend\ Module\ Module Access Gate Registry \TYPO3\CMS\ Backend\ Module\ Module Access Result \TYPO3\,CMS\ Backend\ Module\ Access Gate\ Admin Gate \TYPO3\andCMS\ Backend\ Module\ Access Gate\ User Gate \TYPO3\CMS\ Backend\ Module\ Access Gate\ System Maintainer Gate
The access values user, admin and system are decided by the
\TYPO3\. The gates of
TYPO3 Core for these values are no longer used by TYPO3 Core.
Impact
A module access gate of an extension keeps working until TYPO3 v16.0: it is
asked through a voter for its access value, also when it replaces the gate
of TYPO3 Core for user, admin or system. Asking such a gate
triggers a PHP
E_ error.
Affected installations
Installations with extensions registering a module access gate with the
# attribute, or using the classes listed above.
The extension scanner reports their usage.
Migration
Decide the module access with a security voter. A voter can decide on an access value of its own:
namespace MyVendor\MyExtension\Security;
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
use TYPO3\CMS\Backend\Module\ModuleInterface;
use TYPO3\CMS\Core\Attribute\AsSecurityVoter;
use TYPO3\CMS\Core\Authentication\Principal;
use TYPO3\CMS\Core\Security\Authorization\Policy\Scope;
use TYPO3\CMS\Core\Security\Authorization\SecurityRole;
use TYPO3\CMS\Core\Security\Authorization\Voter\PrincipalVoter;
#[AsSecurityVoter]
final class ProjectLeadModuleVoter extends PrincipalVoter
{
protected function supports(string $attribute, mixed $subject): bool
{
return $attribute === Scope::ACCESS
&& $subject instanceof ModuleInterface
&& $subject->getAccess() === 'projectLead';
}
protected function voteOnPrincipal(
string $attribute,
mixed $subject,
Principal $principal,
?Vote $vote = null,
): bool {
return $this->hasRole($principal, SecurityRole::ADMIN);
}
}
A gate replacing the gate of TYPO3 Core for user, admin or
system only to restrict the access is migrated to a voter that
supports modules with that access value and denies: the denial of a voter
always wins over the grant of the
Module. A voter cannot grant
more than the
Module for these values.