public function SecuresiteSettingsForm::buildForm in Secure Site 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ SecuresiteSettingsForm.php, line 27 - Contains \Drupal\securesite\Form\SecuresiteSettingsForm.
Class
Namespace
Drupal\securesite\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('securesite.settings');
$anonymous_user = new AnonymousUserSession();
$form['authentication'] = array(
'#type' => 'fieldset',
'#title' => t('Authentication'),
'#description' => t('Enable Secure Site below. Users must have the <em>!access</em> permission in order to access the site if authentication is forced.', array(
'!access' => l(t('access secured pages'), 'admin/people/permissions', array(
'fragment' => 'module-securesite',
)),
)),
);
$form['authentication']['securesite_enabled'] = array(
'#type' => 'radios',
'#title' => t('Force authentication'),
'#default_value' => $config
->get('securesite_enabled'),
'#options' => array(
SECURESITE_DISABLED => t('Never'),
SECURESITE_ALWAYS => t('Always'),
SECURESITE_OFFLINE => t('During maintenance'),
),
'#description' => t('Choose when to force authentication.'),
);
$form['authentication']['securesite_type'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed authentication types'),
'#default_value' => $config
->get('securesite_type'),
'#options' => array(
SECURESITE_DIGEST => t('HTTP digest'),
SECURESITE_BASIC => t('HTTP basic'),
SECURESITE_FORM => t('HTML log-in form'),
),
'#required' => TRUE,
);
$form['authentication']['securesite_type']['#description'] = "\n<p>" . t('HTTP authentication requires extra configuration if PHP is not installed as an Apache module. See the !link section of the Secure Site help for details.', array(
'!link' => l(t('Known issues'), 'admin/help/securesite', array(
'fragment' => 'issues',
)),
)) . "</p>\n<p>" . t('Digest authentication protects a user’s password from eavesdroppers when you are not using SSL to encrypt the connection. However, it can only be used when a copy of the password is stored on the server.') . ' ' . t('For security reasons, Drupal does not store passwords. You will need to configure scripts to securely save passwords and authenticate users. See the !link section of the Secure Site help for details.', array(
'!link' => l(t('Secure password storage'), 'admin/help/securesite', array(
'fragment' => 'passwords',
)),
)) . "</p>\n<p>" . t('When digest authentication is enabled, passwords will be saved when users log in or set their passwords. If you use digest authentication to protect your whole site, you should allow guest access or allow another authentication type until users whose passwords are not yet saved have logged in. Otherwise, <strong>you may lock yourself out of your own site.</strong>') . '</p>' . "\n";
$form['authentication']['securesite_digest_script'] = array(
'#type' => 'textarea',
'#title' => t('Digest authentication script'),
'#default_value' => $config
->get('securesite_digest_script'),
'#description' => t('Enter the digest authentication script exactly as it should appear on the command line. Use absolute paths.'),
'#rows' => 2,
);
$form['authentication']['securesite_password_script'] = array(
'#type' => 'textarea',
'#title' => t('Password storage script'),
'#default_value' => $config
->get('securesite_password_script'),
'#description' => t('Enter the password storage script exactly as it should appear on the command line. Use absolute paths.'),
'#rows' => 2,
);
$form['authentication']['securesite_realm'] = array(
'#type' => 'textfield',
'#title' => t('Authentication realm'),
'#default_value' => $config
->get('securesite_realm'),
'#length' => 30,
'#maxlength' => 40,
'#description' => t('Name to identify the log-in area in the HTTP authentication dialog.'),
);
$form['guest'] = array(
'#type' => 'fieldset',
'#title' => t('Guest access'),
'#description' => t('Guest access allows anonymous users to view secure pages, though they will still be prompted for a user name and password. If you give anonymous users the <em>!access</em> permission, you can set the user name and password for anonymous users below.', array(
'!access' => l(t('access secured pages'), 'admin/people/permissions', array(
'fragment' => 'module-securesite',
)),
)),
);
$guest_access = !$anonymous_user
->hasPermission('access secured pages');
$form['guest']['securesite_guest_name'] = array(
'#type' => 'textfield',
'#title' => t('Guest user'),
'#default_value' => $config
->get('securesite_guest_name'),
'#length' => 30,
'#maxlength' => 40,
'#description' => t('Do not use the name of a registered user. Leave empty to accept any name.'),
'#disabled' => $guest_access,
);
$form['guest']['securesite_guest_pass'] = array(
'#type' => 'textfield',
'#title' => t('Guest password'),
'#default_value' => $config
->get('securesite_guest_pass'),
'#length' => 30,
'#maxlength' => 40,
'#description' => t('Leave empty to accept any password.'),
'#disabled' => $guest_access,
);
$form['login_form'] = array(
'#type' => 'fieldset',
'#title' => t('Customize HTML forms'),
'#description' => t('Configure the message displayed on the HTML log-in form (if enabled) and password reset form below.'),
);
$form['login_form']['securesite_login_form'] = array(
'#type' => 'textarea',
'#title' => t('Custom message for HTML log-in form'),
'#default_value' => $config
->get('securesite_login_form'),
'#length' => 60,
'#height' => 3,
);
$form['login_form']['securesite_reset_form'] = array(
'#type' => 'textarea',
'#title' => t('Custom message for password reset form'),
'#default_value' => $config
->get('securesite_reset_form'),
'#length' => 60,
'#height' => 3,
'#description' => t('Leave empty to disable Secure Site’s password reset form.'),
);
return parent::buildForm($form, $form_state);
}