passwordGenerator¶
New in version 12.1
-
passwordGenerator
¶ -
- Type
- boolean
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']
- Scope
- Display
The control renders a button next to the password field allowing the user to generate a random password based on defined rules.
Using the control adds the generated password to the corresponding field. The password is visible to the backend user only once and stored encrypted in the database. Integrators are also able to define whether the user is allowed to edit the generated password before saving.
<?php $GLOBALS['TCA']['tx_myextension_table']['columns']['password_field'] = [ 'label' => 'Password', 'config' => [ 'type' => 'password', 'fieldControl' => [ 'passwordGenerator' => [ 'renderType' => 'passwordGenerator', ], ], ], ];
Copied!
Table of Content
Examples¶
Include special characters¶
Example: qe8)i2W1it-msR8
[
'columns' => [
'password_6' => [
'label' => 'password_6',
'description' => 'type=password fieldControl=passwordGenerator - all character sets',
'config' => [
'type' => 'password',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'title' => 'Create random password',
'passwordRules' => [
'specialCharacters' => true,
],
],
],
],
],
],
],
]
Only digits, length 8 (minimum length)¶
Example: 28233371
[
'columns' => [
'password_7' => [
'label' => 'password_7',
'description' => 'type=password fieldControl=passwordGenerator length=8 - only digits',
'config' => [
'type' => 'password',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'title' => 'Create random number',
'passwordRules' => [
'length' => 8,
'lowerCaseCharacters' => false,
'upperCaseCharacters' => false,
],
],
],
],
],
],
],
]
Hexadecimal random bytes, length 30¶
Example: 0d95c0936c54b97bf908a3c963b508
.
The following example will generate a 30 characters long random hex string, which could be used for secret tokens or similar:
[
'columns' => [
'password_4' => [
'label' => 'password_4',
'description' => 'type=password fieldControl=passwordGenerator random=hex',
'config' => [
'type' => 'password',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'title' => 'Create random hex string',
'passwordRules' => [
'length' => 30,
'random' => 'hex',
],
],
],
],
],
],
],
]
Base64 random bytes, readonly¶
Example: zrt8sJd6GiqUI_EFgjPiedOj--D0NbTVOJz
[
'columns' => [
'password_5' => [
'label' => 'password_5',
'description' => 'type=password fieldControl=passwordGenerator random=base64 allowEdit=false',
'config' => [
'type' => 'password',
'fieldControl' => [
'passwordGenerator' => [
'renderType' => 'passwordGenerator',
'options' => [
'title' => 'Create random base64 string',
'allowEdit' => false,
'passwordRules' => [
'length' => 35,
'random' => 'base64',
],
],
],
],
],
],
],
]
Properties¶
Field control options¶
title¶
-
title
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['title']
- Type
- String / localized string
- Default
"LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.generatePassword"
Define a title for the control button.
allowEdit¶
-
allowEdit
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['allowEdit']
- Type
- boolean
- Default
true
If set to
false
, the user cannot edit the generated password.
Password rules¶
Define rules for the password.
passwordRules.length¶
-
passwordRules.length
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['length']
- Type
- int
- Default
16
- Minimum
8
Defines the amount of characters for the generated password.
passwordRules.random¶
-
passwordRules.random
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['random']
- Type
- String
- Values
"hex"
,"base64"
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_Ag9kG983y-_N2zyLZzof
.
Note
Defining the
passwordRules.random
password rule takes precedence over any character definition, which should therefore be omitted as soon aspasswordRules.random
is set to one of the available encodings:hex
orbase64
.
passwordRules.digitCharacters¶
-
passwordRules.digitCharacters
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['digitCharacters']
- Type
- boolean
- Default
true
If set to
false
, the generated password contains no digit.
passwordRules.lowerCaseCharacters¶
-
passwordRules.lowerCaseCharacters
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['lowerCaseCharacters']
- Type
- boolean
- Default
true
If set to
false
, the generated password contains no lower case characters.
passwordRules.upperCaseCharacters¶
-
passwordRules.upperCaseCharacters
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['upperCaseCharacters']
- Type
- boolean
- Default
true
If set to
false
, the generated password contains no upper case characters.
passwordRules.specialCharacters¶
-
passwordRules.specialCharacters
¶ -
- Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']['passwordGenerator']['options']['passwordRules']['specialCharacters']
- Type
- boolean
- Default
false
If set to
true
, the generated password also contains special characters (!"#$%&\'()*+,-./:;<=>?@[\]^_
{|} `).