Skip to content
Snippets Groups Projects

Issue #3491087 by kalash: Added #config_target.

Open kalash jain requested to merge issue/tfa-3491087:3491087-use-config-target into 2.x
1 file
+ 28
9
Compare changes
  • Side-by-side
  • Inline
+ 28
9
@@ -144,9 +144,10 @@ final class SettingsForm extends ConfigFormBase {
$form['tfa_enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable TFA'),
'#default_value' => $config->get('enabled') && !empty($encryption_profiles),
'#default_value' => $config->get('enabled'),
'#config_target' => 'tfa.settings:enabled',
'#description' => $this->t('Enable TFA for account authentication.'),
'#disabled' => empty($encryption_profiles),
'#disabled' => empty($this->encryptionProfileManager->getAllEncryptionProfiles()),
];
$enabled_state = [
@@ -182,8 +183,9 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'checkboxes',
'#title' => $this->t('Roles required to set up TFA'),
'#options' => $roles_available,
'#default_value' => $config->get('required_roles') ?: [],
'#description' => $this->t('Require users with these roles to set up TFA. Note: If a role does not have the "setup own tfa" permission users will be unable to configure a TFA token without administrator assistance. The account will be locked out once the skip limit is reached unless a token is configured through other methods.'),
'#default_value' => $config->get('required_roles'),
'#config_target' => 'tfa.settings:required_roles',
'#description' => $this->t('Require users with these roles to set up TFA.'),
'#states' => $enabled_state,
'#required' => FALSE,
];
@@ -192,7 +194,8 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'checkboxes',
'#title' => $this->t('Allowed Validation plugins'),
'#options' => $validation_plugins_labels,
'#default_value' => $config->get('allowed_validation_plugins') ?: ['tfa_totp'],
'#default_value' => $config->get('allowed_validation_plugins'),
'#config_target' => 'tfa.settings:allowed_validation_plugins',
'#description' => $this->t('Plugins that can be setup by users for various TFA processes.'),
// Show only when TFA is enabled.
'#states' => $enabled_state,
@@ -202,7 +205,8 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'select',
'#title' => $this->t('Default Validation plugin'),
'#options' => $validation_plugins_labels,
'#default_value' => $config->get('default_validation_plugin') ?: 'tfa_totp',
'#default_value' => $config->get('default_validation_plugin'),
'#config_target' => 'tfa.settings:default_validation_plugin',
'#description' => $this->t('Plugin that will be used as the default TFA process.'),
// Show only when TFA is enabled.
'#states' => $enabled_state,
@@ -257,13 +261,17 @@ final class SettingsForm extends ConfigFormBase {
foreach ($encryption_profiles as $encryption_profile) {
$encryption_profile_labels[$encryption_profile->id()] = $encryption_profile->label();
}
$form['encryption_profile'] = [
'#type' => 'select',
'#title' => $this->t('Encryption Profile'),
'#options' => $encryption_profile_labels,
'#description' => $this->t('Encryption profiles to encrypt the secret'),
'#default_value' => $config->get('encryption'),
'#states' => $enabled_state,
'#config_target' => 'tfa.settings:encryption',
'#description' => $this->t('Encryption profiles to encrypt the secret'),
'#states' => [
'visible' => [':input[name="tfa_enabled"]' => ['checked' => TRUE]],
],
'#required' => TRUE,
];
@@ -279,6 +287,7 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'number',
'#title' => $this->t('Skip Validation'),
'#default_value' => $skip_value ?? 3,
'#config_target' => 'tfa.settings:validation_skip',
'#description' => $this->t('No. of times a user without having setup tfa validation can login.'),
'#min' => 0,
'#max' => 99,
@@ -291,6 +300,7 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'checkbox',
'#title' => $this->t('Redirect users on login to TFA Setup Page'),
'#default_value' => $config->get('users_without_tfa_redirect') ?? FALSE,
'#config_target' => 'tfa.settings:users_without_tfa_redirect',
'#description' => $this->t('If the user has the "setup own tfa" permission and has not yet configured TFA they will be redirected to the TFA overview page after login.'),
];
@@ -308,6 +318,7 @@ final class SettingsForm extends ConfigFormBase {
'#title' => $this->t('Login plugins'),
'#options' => $login_form_array,
'#default_value' => ($config->get('login_plugins')) ? $config->get('login_plugins') : [],
'#config_target' => 'tfa.settings:login_plugins',
'#description' => $this->t('Plugins that can allow a user to skip the TFA process. If any plugin returns true the user will not be required to follow TFA. <strong>Use with caution.</strong>'),
'#states' => $enabled_state,
];
@@ -381,6 +392,7 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'checkbox',
'#title' => $this->t('Flood Control With UID Only'),
'#default_value' => ($config->get('tfa_flood_uid_only')) ?: 0,
'#config_target' => 'tfa.settings:tfa_flood_uid_only',
'#description' => $this->t('Flood control on the basis of uid only.'),
];
@@ -389,6 +401,7 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'number',
'#title' => $this->t('TFA Flood Window'),
'#default_value' => ($config->get('tfa_flood_window')) ?: 300,
'#config_target' => 'tfa.settings:tfa_flood_window',
'#description' => $this->t('TFA Flood Window.'),
'#min' => 1,
'#size' => 5,
@@ -400,6 +413,7 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'number',
'#title' => $this->t('TFA Flood Threshold'),
'#default_value' => ($config->get('tfa_flood_threshold')) ?: 6,
'#config_target' => 'tfa.settings:tfa_flood_threshold',
'#description' => $this->t('TFA Flood Threshold.'),
'#min' => 1,
'#size' => 2,
@@ -427,12 +441,14 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $config->get('mail.tfa_enabled_configuration.subject'),
'#config_target' => 'tfa.settings:mail.tfa_enabled_configuration.subject',
'#required' => TRUE,
],
'tfa_enabled_configuration_body' => [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $config->get('mail.tfa_enabled_configuration.body'),
'#config_target' => 'tfa.settings:mail.tfa_enabled_configuration.body',
'#required' => TRUE,
'#attributes' => [
'rows' => 10,
@@ -448,12 +464,14 @@ final class SettingsForm extends ConfigFormBase {
'#type' => 'textfield',
'#title' => $this->t('Subject'),
'#default_value' => $config->get('mail.tfa_disabled_configuration.subject'),
'#config_target' => 'tfa.settings:mail.tfa_disabled_configuration.subject',
'#required' => TRUE,
],
'tfa_disabled_configuration_body' => [
'#type' => 'textarea',
'#title' => $this->t('Body'),
'#default_value' => $config->get('mail.tfa_disabled_configuration.body'),
'#config_target' => 'tfa.settings:mail.tfa_disabled_configuration.body',
'#required' => TRUE,
'#attributes' => [
'rows' => 10,
@@ -463,8 +481,9 @@ final class SettingsForm extends ConfigFormBase {
$form['help_text'] = [
'#type' => 'textfield',
'#title' => $this->t('Help text'),
'#description' => $this->t('Text to display when a user is locked out and blocked from logging in.'),
'#default_value' => $config->get('help_text'),
'#config_target' => 'tfa.settings:help_text',
'#description' => $this->t('Text to display when a user is locked out and blocked from logging in.'),
'#required' => TRUE,
];
Loading