Password generator 

New in version 14.2

Introduced to replace the now deprecated passwordRules option of the passwordGenerator 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['TYPO3_CONF_VARS']['SYS']['passwordPolicies'] .

Each password policy can define a generator section. The generator must use a class implementing PasswordGeneratorInterface .

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:

Default password generator
<?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,
  ],
];
Copied!

You can configure its options by overriding or adding them in your config/system/additional.php or typo3conf/system/additional.php:

config/system/additional.php
<?php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['length'] = 20;
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['default']['generator']['options']['specialCharacters'] = false;
Copied!

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\CMS\Core\PasswordPolicy\Generator\PasswordGeneratorInterface and referencing the class in the policy configuration:

config/system/additional.php
<?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';
Copied!

The generator options are passed to the configured generator class.