You are here

class AdvancedSettings in Shibboleth Authentication 8

Class AdvancedSettings.

@package Drupal\shib_auth\Form

Hierarchy

Expanded class hierarchy of AdvancedSettings

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

File

src/Form/AdvancedSettings.php, line 13

Namespace

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

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

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

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('shib_auth.advancedsettings');

    // $form['strict_shibboleth_session_checking'] = array(
    //      '#type' => 'details',
    //      '#title' => $this->t('Strict Shibboleth Session Checking'),
    //      '#open' => 'open',
    //    );
    //    $form['strict_shibboleth_session_checking']['Destroy Session'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('Destroy Drupal session when the Shibboleth session expires.'),
    //      '#default_value' => $config->get('Destroy Session'),
    //    ];
    //    $form['terms_of_use_settings'] = array(
    //      '#type' => 'details',
    //      '#title' => $this->t('Terms of Use Settings'),
    //      '#open' => 'open',
    //    );
    //    $form['terms_of_use_settings']['force_terms_of_use'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('Force users to accept Terms of Use'),
    //      '#default_value' => $config->get('force_terms_of_use'),
    //    ];
    //    $form['terms_of_use_settings']['url_of_document'] = [
    //      '#type' => 'textfield',
    //      '#title' => $this->t('URL of the document'),
    //      '#description' => $this->t('Please refence local content with e.g. "node/1", or use an external link.'),
    //      '#maxlength' => 128,
    //      '#size' => 64,
    //      '#default_value' => $config->get('url_of_document'),
    //    ];
    //    $form['terms_of_use_settings']['document_version'] = [
    //      '#type' => 'textfield',
    //      '#title' => $this->t('Document version'),
    //      '#maxlength' => 64,
    //      '#size' => 10,
    //      '#default_value' => $config->get('document_version'),
    //    ];.
    $form['login_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Login Settings'),
      '#open' => 'open',
    ];
    $form['login_settings']['url_redirect_login'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('URL to redirect to after login'),
      '#description' => $this
        ->t('The URL can be absolute or relative to the server base url. The relative paths will be automatically extended with the site base URL. If this value is empty, then the user will be redirected to the originally requested page.'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('url_redirect_login'),
    ];
    $form['logout_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Logout Settings'),
      '#open' => 'open',
    ];
    $form['logout_settings']['url_redirect_logout'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('URL to redirect to after logout'),
      '#description' => $this
        ->t('The URL can be absolute or relative to the server base url. The relative paths will be automatically extended with the site base URL. If you are using SLO, this setting is probably useless (depending on the IdP)'),
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => $config
        ->get('url_redirect_logout'),
    ];
    $form['logout_settings']['logout_error_message'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('Error Page Message'),
      '#default_value' => $config
        ->get('logout_error_message'),
      '#description' => $this
        ->t('Error message displayed to the user (if an error occurs).'),
    ];

    // $form['advanced_saml2_settings'] = array(
    //      '#type' => 'details',
    //      '#title' => $this->t('Advanced SAML2 Settings'),
    //      '#open' => 'open',
    //    );
    //    $form['advanced_saml2_settings']['enable_passive_authentication'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('Enable passive authentication'),
    //      '#description' => $this->t('Enable passive authentication'),
    //      '#default_value' => $config->get('enable_passive_authentication'),
    //    ];
    //    $form['advanced_saml2_settings']['enable_forced_authentication'] = [
    //      '#type' => 'checkbox',
    //      '#title' => $this->t('Enable forced authentication'),
    //      '#description' => $this->t('Enable forced authentication'),
    //      '#default_value' => $config->get('enable_forced_authentication'),
    //    ];.
    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.advancedsettings')
      ->set('url_redirect_logout', $form_state
      ->getValue('url_redirect_logout'))
      ->set('logout_error_message', $form_state
      ->getValue('logout_error_message'))
      ->set('url_redirect_login', $form_state
      ->getValue('url_redirect_login'))
      ->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
AdvancedSettings::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
AdvancedSettings::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
AdvancedSettings::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
AdvancedSettings::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
AdvancedSettings::validateForm public function Form validation handler. Overrides FormBase::validateForm
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.
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.