Feature: #69190 - Add password generator "wizard"
See forge#69190
Description
Password generation in the backend is now driven by password policies. Each
password policy can define a generator section through a class implementing
\TYPO3\.
The password field control references a policy by name via the
password option. The dice icon button next to the field generates
a password using the configured generator.
The field control can be added to any password field via TCA configuration, making it available to extension developers as well.
Password policies
Which policy to use is determined by context:
- Backend users:
$GLOBALS['TYPO3_ CONF_ VARS'] ['BE'] ['password Policy'] - Frontend users:
$GLOBALS['TYPO3_ CONF_ VARS'] ['FE'] ['password Policy']
All password policies are registered under
$GLOBALS.
TYPO3 ships with three preconfigured policies:
default— Used for backend and frontend usersinstall— Used for Install Tool passwordsTool secret— Used for secret token fields (e.g. webhooks, reactions)Token
Each policy contains both a generator and a validators section. The
generator is responsible for creating passwords, while validators enforce
password requirements. They are configured independently within the same
policy.
Example
TYPO3 ships with a
Password
implementation that is configured like this:
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator'] = [
'className' => \TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator::class,
'options' => [
'length' => 12,
'upperCaseCharacters' => true,
'lowerCaseCharacters' => true,
'digitCharacters' => true,
'specialCharacters' => true,
],
];
The
Password
supports the following options:
length: Length of the generated passwordupper: Whether to include uppercase charactersCase Characters lower: Whether to include lowercase charactersCase Characters digit: Whether to include digitsCharacters special: Whether to include special charactersCharacters
Adjusting an existing policy:
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['length'] = 20;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['specialCharacters'] = false;
Registering a custom password policy with a custom generator:
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['customPolicy'] = [
'generator' => [
'className' => \Vendor\MyPackage\PasswordPolicy\Generator\MyPasswordGenerator::class,
'options' => [
'length' => 12,
'myCustomOption' => 'my custom value',
],
],
'validators' => [
// Your custom validators
],
];
$GLOBALS['TYPO3_CONF_VARS']['BE']['passwordPolicy'] = 'customPolicy';
$GLOBALS['TYPO3_CONF_VARS']['FE']['passwordPolicy'] = 'customPolicy';
Impact
Password generation for backend and frontend users is now configurable through
password policies. The Install Tool command
vendor/ also respects the configured
policy.