You are here

public function LocalSettingsForm::buildForm in simpleSAMLphp Authentication 8.3

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/LocalSettingsForm.php, line 30

Class

LocalSettingsForm
Form builder for the simplesamlphp_auth local settings form.

Namespace

Drupal\simplesamlphp_auth\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('simplesamlphp_auth.settings');
  $form['authentication'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Drupal authentication'),
    '#collapsible' => FALSE,
  ];
  $form['authentication']['allow_default_login'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow authentication with local Drupal accounts'),
    '#default_value' => $config
      ->get('allow.default_login'),
    '#description' => $this
      ->t('Check this box if you want to let people log in with local Drupal accounts (without using simpleSAMLphp). If this is not selected, users will be directly redirected to the external identity provider. If this is selected, you can restrict this privilege to certain users below.'),
  ];
  $form['authentication']['allow_set_drupal_pwd'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow SAML users to set Drupal passwords'),
    '#default_value' => $config
      ->get('allow.set_drupal_pwd'),
    '#description' => $this
      ->t('Check this box if you want to let people set passwords for their local Drupal accounts. This will allow users to log in using either SAML or a local Drupal account. Disabling this removes the password change fields from the user profile form.<br/>NOTE: In order for them to login using their local Drupal password you must allow local logins with the settings below.'),
  ];
  $form['authentication']['allow_default_login_roles'] = [
    '#type' => 'checkboxes',
    '#size' => 3,
    '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', user_role_names(TRUE)),
    '#multiple' => TRUE,
    '#title' => $this
      ->t('Which ROLES should be allowed to login with local accounts?'),
    '#default_value' => $config
      ->get('allow.default_login_roles'),
    '#description' => $this
      ->t('Roles that should be allowed to login without simpleSAMLphp. Examples are dev/admin roles or guest roles.'),
  ];
  $form['authentication']['allow_default_login_users'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Which users should be allowed to login with local accounts?'),
    '#default_value' => $config
      ->get('allow.default_login_users'),
    '#description' => $this
      ->t('Example: <i>1,2,3</i><br />A comma-separated list of user IDs that should be allowed to login without simpleSAMLphp.'),
  ];
  $form['authentication']['logout_goto_url'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Redirect URL after logging out'),
    '#default_value' => $config
      ->get('logout_goto_url'),
    '#description' => $this
      ->t('Optionally, specify a URL for users to go to after logging out.'),
  ];
  return parent::buildForm($form, $form_state);
}