You are here

public function SecuritytxtConfigureForm::buildForm in Security.txt 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/SecuritytxtConfigureForm.php, line 58

Class

SecuritytxtConfigureForm
Configure the security.txt file.

Namespace

Drupal\securitytxt\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['enabled'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable the security.txt file for your site'),
    '#default_value' => $this->settings
      ->get('enabled'),
    '#description' => $this
      ->t('When enabled the security.txt file will be accessible to all users with the "view securitytxt" permission, you will almost certinaly want to give this permission to everyone i.e. authenticated and anonymous users.'),
  ];
  $form['contact'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Contact'),
    '#open' => TRUE,
    '#description' => $this
      ->t('You must provide at least one means of contact: email, phone or contact page URL.'),
  ];
  $form['contact']['contact_email'] = [
    '#type' => 'email',
    '#title' => $this
      ->t('Email'),
    '#default_value' => $this->settings
      ->get('contact_email'),
    '#description' => $this
      ->t('Typically this would be of the form <kbd>security@example.com</kbd>. Leave it blank if you do not want to provide an email address.'),
  ];
  $form['contact']['contact_phone'] = [
    '#type' => 'tel',
    '#title' => $this
      ->t('Phone'),
    '#default_value' => $this->settings
      ->get('contact_phone'),
    '#description' => $this
      ->t('Use full international format e.g. <kbd>+1-201-555-0123</kbd>. Leave it blank if you do not want to provide a phone number.'),
  ];
  $form['contact']['contact_url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('URL'),
    '#default_value' => $this->settings
      ->get('contact_url'),
    '#description' => $this
      ->t('The URL of a contact page which should be loaded over HTTPS. Leave it blank if you do not want to provide a contact page.'),
  ];
  $form['encryption'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Encryption'),
    '#open' => TRUE,
    '#description' => $this
      ->t('Allow people to send you encrypted messages by providing your public key.'),
  ];
  $form['encryption']['encryption_key_url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Public key URL'),
    '#default_value' => $this->settings
      ->get('encryption_key_url'),
    '#description' => $this
      ->t('The URL of your public key file, or a page which contains your public key. This URL should use the HTTPS protocol.'),
  ];
  $form['policy'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Policy'),
    '#open' => TRUE,
    '#description' => $this
      ->t('A security and/or disclosure policy can help security researchers understand  how to work with you when reporting security vulnerabilities.'),
  ];
  $form['policy']['policy_url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Security policy URL'),
    '#default_value' => $this->settings
      ->get('policy_url'),
    '#description' => $this
      ->t('The URL of a page which provides details of your security and/or disclosure policy. Leave it blank if you do not have such a page.'),
  ];
  $form['acknowledgement'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Acknowledgement'),
    '#open' => TRUE,
    '#description' => $this
      ->t('A security acknowldgements page should list the individuals or companies that have disclosed security vulnerabilities and worked with you to fix them.'),
  ];
  $form['acknowledgement']['acknowledgement_url'] = [
    '#type' => 'url',
    '#title' => $this
      ->t('Acknowledgements page URL'),
    '#default_value' => $this->settings
      ->get('acknowledgement_url'),
    '#description' => $this
      ->t('The URL of your security acknowledgements page. Leave it blank if you do not have such a page.'),
  ];
  return parent::buildForm($form, $form_state);
}