You are here

public function BasicSettingsForm::buildForm in Auth0 Single Sign On 8

Same name and namespace in other branches
  1. 8.2 src/Form/BasicSettingsForm.php \Drupal\auth0\Form\BasicSettingsForm::buildForm()

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 FormInterface::buildForm

File

src/Form/BasicSettingsForm.php, line 27
Contains \Drupal\auth0\Form\BasicSettingsForm.

Class

BasicSettingsForm
This forms handles the basic module configurations.

Namespace

Drupal\auth0\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = \Drupal::service('config.factory')
    ->get('auth0.settings');
  $form['auth0_client_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Client id'),
    '#default_value' => $config
      ->get('auth0_client_id', ''),
    '#description' => t('Application id, copy from the auth0 dashboard.'),
    '#required' => TRUE,
  );
  $form['auth0_client_secret'] = array(
    '#type' => 'textfield',
    '#title' => t('Client secret'),
    '#default_value' => $config
      ->get('auth0_client_secret', ''),
    '#description' => t('Application secret, copy from the auth0 dashboard.'),
    '#required' => TRUE,
  );
  $form['auth0_secret_base64_encoded'] = array(
    '#type' => 'checkbox',
    '#title' => t('Client Secret is Base64 Encoded'),
    '#default_value' => $config
      ->get('auth0_secret_base64_encoded'),
    '#description' => t('This is stated below the client secret in your Auth0 Dashboard for the client.  If your client was created after September 2016, this should be false.'),
  );
  $form['auth0_domain'] = array(
    '#type' => 'textfield',
    '#title' => t('Domain'),
    '#default_value' => $config
      ->get('auth0_domain', ''),
    '#description' => t('Your Auth0 domain, you can see it in the auth0 dashboard.'),
    '#required' => TRUE,
  );
  $form['auth0_jwt_signature_alg'] = array(
    '#type' => 'select',
    '#title' => t('JWT Signature Algorithm'),
    '#options' => [
      'HS256' => $this
        ->t('HS256'),
      'RS256' => $this
        ->t('RS256'),
    ],
    '#default_value' => $config
      ->get('auth0_jwt_signature_alg', 'HS256'),
    '#description' => t('Your JWT Signing Algorithm for the ID token.  RS256 is recommended, but must be set in the advanced settings under oauth for this client.'),
    '#required' => TRUE,
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#button_type' => 'primary',
  );
  return $form;
}