Password generator
New in version 14.2
Introduced to replace the now deprecated password option
of the password field control
TYPO3 provides a password generator field control for TCA fields. It can be used to generate passwords or secret values directly in backend forms.
Password generation is configured through password policies registered in
$GLOBALS.
Each password policy can define a generator section. The generator must
use a class implementing
Password.
The TCA field control references the password policy by name via the passwordPolicy option.
Configure a password generator
By default the following password policy generator is defined:
<?php
use TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator'] = [
'className' => PasswordGenerator::class,
'options' => [
'length' => 12,
'upperCaseCharacters' => true,
'lowerCaseCharacters' => true,
'digitCharacters' => true,
'specialCharacters' => true,
],
];
You can configure its options by overriding or adding them in your
config/ or typo3conf/:
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['length'] = 20;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['specialCharacters'] = false;
See the available options below:
Available password generator options
The default password generator supports the following options:
| Name | Type | Default |
|---|---|---|
| integer | 12 | |
| boolean | true | |
| boolean | true | |
| boolean | true | |
| boolean | true |
length
-
- Type
- integer
- Default
- 12
Defines the length of the generated password.
upperCaseCharacters
-
- Type
- boolean
- Default
- true
Whether uppercase characters should be used.
lowerCaseCharacters
-
- Type
- boolean
- Default
- true
Whether lowercase characters should be used.
digitCharacters
-
- Type
- boolean
- Default
- true
Whether digits should be used.
specialCharacters
-
- Type
- boolean
- Default
- true
Whether special characters should be used.
Custom password generators
A custom password generator can be used by implementing
\TYPO3\
and referencing the class in the policy configuration:
<?php
use MyVendor\MyExtension\PasswordPolicy\Generator\MyPasswordGenerator;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['customGeneratorPolicy'] = [
'generator' => [
'className' => MyPasswordGenerator::class,
'options' => [
'length' => 32,
],
],
'validators' => [
// Your custom validators
],
];
$GLOBALS['TYPO3_CONF_VARS']['BE']['passwordPolicy'] = 'customPolicy';
$GLOBALS['TYPO3_CONF_VARS']['FE']['passwordPolicy'] = 'customPolicy';
The generator options are passed to the configured generator class.