You are here

class ShibbolethSettings in Shibboleth Authentication 8

Class ShibbolethSettings.

@package Drupal\shib_auth\Form

Hierarchy

Expanded class hierarchy of ShibbolethSettings

1 string reference to 'ShibbolethSettings'
shib_auth.routing.yml in ./shib_auth.routing.yml
shib_auth.routing.yml

File

src/Form/ShibbolethSettings.php, line 13

Namespace

Drupal\shib_auth\Form
View source
class ShibbolethSettings extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'shib_auth.shibbolethsettings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'shibboleth_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('shib_auth.shibbolethsettings');
    $form['shibboleth_handler_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Shibboleth Handler Settings'),
      '#open' => 'open',
    ];
    $form['shibboleth_handler_settings']['shibboleth_login_handler_url'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Shibboleth login handler URL'),
      '#description' => $this
        ->t('The URL can be absolute or relative to the server base url: http://www.example.com/Shibboleth.sso/DS; /Shibboleth.sso/DS'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('shibboleth_login_handler_url'),
    ];
    $form['shibboleth_handler_settings']['shibboleth_logout_handler_url'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Shibboleth logout handler URL'),
      '#description' => $this
        ->t('The URL can be absolute or relative to the server base url: http://www.example.com/Shibboleth.sso/Logout; /Shibboleth.sso/Logout'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('shibboleth_logout_handler_url'),
    ];
    $form['shibboleth_handler_settings']['shibboleth_login_link_text'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Shibboleth login link text'),
      '#description' => $this
        ->t('The text of the login link. You can change this text on the Shibboleth login block settings form too!'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('shibboleth_login_link_text'),
    ];
    $form['shibboleth_handler_settings']['force_https_on_login'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Force HTTPS on login'),
      '#description' => $this
        ->t('The user will be redirected to HTTPS'),
      '#default_value' => $config
        ->get('force_https_on_login'),
    ];
    $form['attribute_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Attribute Settings'),
      '#open' => 'open',
    ];
    $form['attribute_settings']['server_variable_username'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Server variable for username'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('server_variable_username'),
    ];
    $form['attribute_settings']['server_variable_email'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Server variable for e-mail address'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('server_variable_email'),
    ];

    // $form['attribute_settings']['user_defined_usernames'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('User-defined usernames'),
    //      '#description' => $this->t('Allow users to set their Drupal usernames at first Shibboleth login. Note that disabling this option only prevents new users from registering their own username. Existing user-defined usernames will remain valid.'),
    //      '#default_value' => $config->get('user_defined_usernames'),
    //    ];
    //    $form['attribute_settings']['user_defined_email'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('User-defined email addresses'),
    //      '#description' => $this->t('Ask users to set their contact email address at first login. Disabling this option will override contact address with the one, which was received from IdP. (In this case, missing e-mail address will result in fatal error.)'),
    //      '#default_value' => $config->get('user_defined_email'),
    //    ];
    //    $form['attribute_settings']['account_linking'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('Account Linking'),
    //      '#description' => $this->t('Allow locally authenticated users to link their Drupal accounts to federated logins. Note that disabling this option only prevents from creating/removing associations, existing links will remain valid.'),
    //      '#default_value' => $config->get('account_linking'),
    //    ];
    //    $form['attribute_settings']['shibboleth_account_linking_text'] = [
    //      '#type' => 'textfield',
    //      '#title' => $this->t('Shibboleth account linking text'),
    //      '#description' => $this->t('The text of the link providing account linking shown on the user settings form.'),
    //      '#maxlength' => 128,
    //      '#size' => 64,
    //      '#default_value' => $config->get('shibboleth_account_linking_text'),
    //    ];.
    $form['debugging_options'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Debugging Options'),
      '#open' => 'open',
    ];
    $form['debugging_options']['enable_debug_mode'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable DEBUG mode.'),
      '#default_value' => $config
        ->get('enable_debug_mode'),
    ];
    $form['debugging_options']['debug_prefix_path'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('DEBUG path prefix'),
      '#description' => $this
        ->t("For example, use \"/user/\" to display DEBUG messages on paths like \"/user/*\"."),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('debug_prefix_path'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $this
      ->config('shib_auth.shibbolethsettings')
      ->set('shibboleth_login_handler_url', $form_state
      ->getValue('shibboleth_login_handler_url'))
      ->set('shibboleth_logout_handler_url', $form_state
      ->getValue('shibboleth_logout_handler_url'))
      ->set('shibboleth_login_link_text', $form_state
      ->getValue('shibboleth_login_link_text'))
      ->set('force_https_on_login', $form_state
      ->getValue('force_https_on_login'))
      ->set('server_variable_username', $form_state
      ->getValue('server_variable_username'))
      ->set('server_variable_email', $form_state
      ->getValue('server_variable_email'))
      ->set('enable_debug_mode', $form_state
      ->getValue('enable_debug_mode'))
      ->set('debug_prefix_path', $form_state
      ->getValue('debug_prefix_path'))
      ->save();

    // Invalidate the cache for the Shib login block.
    \Drupal::service('cache_tags.invalidator')
      ->invalidateTags([
      'shibboleth_login_block',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
ShibbolethSettings::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
ShibbolethSettings::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
ShibbolethSettings::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
ShibbolethSettings::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
ShibbolethSettings::validateForm public function Form validation handler. Overrides FormBase::validateForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.