Password generator examples
Include special characters
Example: qe8)i2W1it-
The password of the live stream with its generator
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'livestream_password' => [
'label' => 'my_extension.db:conference.livestream_password',
'displayCond' => 'FIELD:event_format:IN:online,hybrid',
'config' => [
'type' => 'password',
'hashed' => false,
'passwordPolicy' => 'default',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'passwordPolicy' => 'default',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'livestream_password',
'',
'after:stream_url',
);
Only digits, length 8 (minimum length)
Example: 28233371
The door code of a room uses the policy my. The extension
defines it in its ext_localconf.php, and its generator creates
8 digits:
<?php
use MyVendor\MyExtension\Controller\ConferenceController;
use MyVendor\MyExtension\Evaluation\AbstractEvaluation;
use MyVendor\MyExtension\Evaluation\HashtagEvaluation;
use MyVendor\MyExtension\Form\Element\BadgeNameElement;
use MyVendor\MyExtension\Form\FieldInformation\InformationText;
use MyVendor\MyExtension\Form\FieldInformation\TalkOrderInformation;
use MyVendor\MyExtension\Form\FieldWizard\ReferencesToThisRecordWizard;
use TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') or die();
ExtensionUtility::configurePlugin(
'MyExtension',
'ConferenceList',
[ConferenceController::class => ['list', 'show']],
);
// Classes that TCA fields name in 'eval'
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][HashtagEvaluation::class] = '';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][AbstractEvaluation::class] = '';
// The information above the talks of a conference, see
// Configuration/TCA/Overrides/120-tx_myextension_conference-talks.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791234567] = [
'nodeName' => 'talkOrderInformation',
'priority' => 30,
'class' => TalkOrderInformation::class,
];
// The badge name of a frontend user, see
// Configuration/TCA/Overrides/650-fe_users-tx_myextension_badge_name.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791300000] = [
'nodeName' => 'badgeName',
'priority' => 40,
'class' => BadgeNameElement::class,
];
// The information text of fields, see for example
// Configuration/TCA/Overrides/310-tx_myextension_speaker-email.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791310000] = [
'nodeName' => 'informationText',
'priority' => 30,
'class' => InformationText::class,
];
// The references to a conference above its form, see
// Configuration/TCA/Overrides/101-tx_myextension_conference-references.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791320000] = [
'nodeName' => 'referencesToThisRecord',
'priority' => 30,
'class' => ReferencesToThisRecordWizard::class,
];
// The password policies of the password generators, see
// Configuration/TCA/Overrides/445-tx_myextension_location-door_code.php and
// Configuration/TCA/Overrides/345-tx_myextension_speaker-upload_token.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionDigits'] = [
'generator' => [
'className' => PasswordGenerator::class,
'options' => [
'length' => 8,
'lowerCaseCharacters' => false,
'upperCaseCharacters' => false,
'digitCharacters' => true,
],
],
'validators' => [],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionBase64'] = [
'generator' => [
'className' => PasswordGenerator::class,
'options' => [
'length' => 35,
'random' => 'base64',
],
],
'validators' => [],
];
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_location', [
'door_code' => [
'label' => 'my_extension.db:location.door_code',
'config' => [
'type' => 'password',
'hashed' => false,
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
// The keypad at the door of the room has only digits
'passwordPolicy' => 'myExtensionDigits',
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_location',
'door_code',
'',
'after:capacity',
);
Hexadecimal random bytes, length 40
Example: a3f1c9e07b5d4e2f8c6a1b0d9e7f3c5a2b4d6e8f
The secret of the ticket shop, generated as a hex string
The secret of the ticket shop uses the policy secret of the Core. Its
generator creates a random hex string with 40 characters:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'ticketing_secret' => [
'label' => 'my_extension.db:conference.ticketing_secret',
'config' => [
'type' => 'password',
'hashed' => false,
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'passwordPolicy' => 'secretToken',
'allowEdit' => false,
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'ticketing_secret',
'',
'after:prices',
);
Base64 random bytes, readonly
Example: zrt8s
The token of the upload link of a speaker uses the policy
my of the extension. Its generator creates a random base64
string with 35 characters, and the editors cannot change it:
<?php
use MyVendor\MyExtension\Controller\ConferenceController;
use MyVendor\MyExtension\Evaluation\AbstractEvaluation;
use MyVendor\MyExtension\Evaluation\HashtagEvaluation;
use MyVendor\MyExtension\Form\Element\BadgeNameElement;
use MyVendor\MyExtension\Form\FieldInformation\InformationText;
use MyVendor\MyExtension\Form\FieldInformation\TalkOrderInformation;
use MyVendor\MyExtension\Form\FieldWizard\ReferencesToThisRecordWizard;
use TYPO3\CMS\Core\PasswordPolicy\Generator\PasswordGenerator;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') or die();
ExtensionUtility::configurePlugin(
'MyExtension',
'ConferenceList',
[ConferenceController::class => ['list', 'show']],
);
// Classes that TCA fields name in 'eval'
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][HashtagEvaluation::class] = '';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][AbstractEvaluation::class] = '';
// The information above the talks of a conference, see
// Configuration/TCA/Overrides/120-tx_myextension_conference-talks.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791234567] = [
'nodeName' => 'talkOrderInformation',
'priority' => 30,
'class' => TalkOrderInformation::class,
];
// The badge name of a frontend user, see
// Configuration/TCA/Overrides/650-fe_users-tx_myextension_badge_name.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791300000] = [
'nodeName' => 'badgeName',
'priority' => 40,
'class' => BadgeNameElement::class,
];
// The information text of fields, see for example
// Configuration/TCA/Overrides/310-tx_myextension_speaker-email.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791310000] = [
'nodeName' => 'informationText',
'priority' => 30,
'class' => InformationText::class,
];
// The references to a conference above its form, see
// Configuration/TCA/Overrides/101-tx_myextension_conference-references.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1791320000] = [
'nodeName' => 'referencesToThisRecord',
'priority' => 30,
'class' => ReferencesToThisRecordWizard::class,
];
// The password policies of the password generators, see
// Configuration/TCA/Overrides/445-tx_myextension_location-door_code.php and
// Configuration/TCA/Overrides/345-tx_myextension_speaker-upload_token.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionDigits'] = [
'generator' => [
'className' => PasswordGenerator::class,
'options' => [
'length' => 8,
'lowerCaseCharacters' => false,
'upperCaseCharacters' => false,
'digitCharacters' => true,
],
],
'validators' => [],
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['passwordPolicies']['myExtensionBase64'] = [
'generator' => [
'className' => PasswordGenerator::class,
'options' => [
'length' => 35,
'random' => 'base64',
],
],
'validators' => [],
];
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_speaker', [
'upload_token' => [
'label' => 'my_extension.db:speaker.upload_token',
'config' => [
'type' => 'password',
'hashed' => false,
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
// The token is part of the link with which the speaker uploads
// the slides, so the editors cannot choose it themselves
'passwordPolicy' => 'myExtensionBase64',
'allowEdit' => false,
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_speaker',
'upload_token',
'',
'after:identifier',
);
Properties
Field control options
title
-
- Type
- String / localized string
- Default
LLL:core. core: labels. generate Password - TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['title']
Define a title for the control button.
allowEdit
-
- Type
- boolean
- Default
true- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['allowEdit']
If set to
false, the user cannot edit the generated password.
Password policy
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordPolicy']
- Examples
- Digits for a door code, Hex string for a secret, Base64 string for a token
- Added
- 14.2
This option can be used to configure which Password policy should be used for the password field. Use the key of the policy as defined in
$GLOBALS.['TYPO3_ CONF_ VARS'] ['SYS'] ['password Policies'] The field control uses the
generatorsection of the policy. If the option is missing, or the policy has no generator, the field shows no password generator.
Password rules
Deprecated since version 14.2
The password option of the password field control has been
deprecated. Password generation is now configured through
Password policies
registered in
$GLOBALS.
Define rules for the password.
Migration from passwordRules to password policies
Replace the password option with a Password policiy reference.
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
- 'passwordRules' => [
- 'length' => 20,
- 'upperCaseCharacters' => true,
- 'lowerCaseCharacters' => true,
- 'digitCharacters' => true,
- 'specialCharacters' => false,
- ],
+ 'passwordPolicy' => 'myCustomPolicy',
],
],
],
passwordRules.length
-
- Type
- int
- Default
16- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['length']
- Minimum
8
Deprecated since version 14.2
Defines the amount of characters for the generated password.
passwordRules.random
-
- Type
- String
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['random']
- Values
"hex","base64"
Deprecated since version 14.2
Defines the encoding of random bytes. Overrules character definitions.
"hex"- Generates a random password in hexadecimal format. Example:
d0f4030d568ab483b8442735e9e3a7. "base64"- Generates a random password in base64 format. Example:
dtbpykd4vf1hda_.Ag9k G983y-_ N2zy LZzof
Note
Defining the
passwordpassword rule takes precedence over any character definition, which should therefore be omitted as soon asRules. random passwordis set to one of the available encodings:Rules. random hexorbase64.
passwordRules.digitCharacters
-
- Type
- boolean
- Default
true- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['digitCharacters']
Deprecated since version 14.2
If set to
false, the generated password contains no digit.
passwordRules.lowerCaseCharacters
-
- Type
- boolean
- Default
true- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['lowerCaseCharacters']
Deprecated since version 14.2
If set to
false, the generated password contains no lower case characters.
passwordRules.upperCaseCharacters
-
- Type
- boolean
- Default
true- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['upperCaseCharacters']
Deprecated since version 14.2
If set to
false, the generated password contains no upper case characters.
passwordRules.specialCharacters
-
- Type
- boolean
- Default
false- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['specialCharacters']
Deprecated since version 14.2
If set to
true, the generated password also contains special characters (!"#$%&'{|} `).()*+,-./:;<=>?@ []^_