You are here

class MiniorangeIDPSetup in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Hierarchy

Expanded class hierarchy of MiniorangeIDPSetup

1 string reference to 'MiniorangeIDPSetup'
miniorange_saml.routing.yml in ./miniorange_saml.routing.yml
miniorange_saml.routing.yml

File

src/Form/MiniorangeIDPSetup.php, line 16
Contains \Drupal\miniorange_saml\Form\MiniorangeIDPSetup.

Namespace

Drupal\miniorange_saml\Form
View source
class MiniorangeIDPSetup extends FormBase {
  public function getFormId() {
    return 'miniorange_saml_idp_setup';
  }
  public function buildForm(array $form, FormStateInterface $form_state) {
    $module_path = \Drupal::service('extension.list.module')
      ->getPath('miniorange_saml');
    Utilities::visual_tour_start($form, $form_state);
    $base_url = Utilities::getBaseUrl();
    $acs_url = $base_url . '/samlassertion';
    $form['miniorange_saml_copy_button'] = array(
      '#attached' => array(
        'library' => array(
          'miniorange_saml/miniorange_saml_copy.icon',
          'miniorange_saml/miniorange_saml.admin',
        ),
      ),
      '#prefix' => '<div class="mo_saml_sp_table_layout_1"><div class="mo_saml_table_layout mo_saml_sp_container">',
    );

    /**
     * Create container to hold @ServiceProviderMetadata form elements.
     */
    $form['mo_saml_metadata_option'] = array(
      '#markup' => t('<div class="mo_saml_font_for_heading">Service Provider Metadata</div><a id="Restart_moTour" class="mo_btn mo_btn-primary mo_btn-sm mo_tour_button_float" onclick="Restart_moTour()">Take a Tour</a><p style="clear: both"></p><hr>
                                '),
    );
    $form['mo_saml_service_provider_metadata'] = array(
      '#type' => 'fieldset',
      //'#title' => t('Service Provider Metadata'),
      '#attributes' => array(
        'style' => 'padding:2% 2% 5%; margin-bottom:2%',
      ),
    );
    $form['mo_saml_service_provider_metadata']['markup_idp_sp_2'] = array(
      '#markup' => t('<br><div class="mo_saml_font_SP_setup_for_heading"><strong>Provide this module information to your Identity Provider team.<br> You can choose any one of the below options.</strong></div>
                          <br><b>a) Provide this metadata URL to your Identity Provider:</b><br><div>
                            <div class="mo_saml_highlight_background_url_note" id="idp_metadata_url">
                                <code><b>
                                    <span>
                                        <a target="_blank" href="' . $base_url . '/saml_metadata">' . $base_url . '/saml_metadata' . '</a>
                                    </span></b>
                                </code>
                            </div>
                            <img class ="fa fa-fw fa-lg fa-copy mo_copy mo-margin" src="' . $base_url . '/' . $module_path . '/includes/images/copy-regular.svg">
                        </div>'),
    );
    $form['mo_saml_service_provider_metadata']['mo_saml_download_btn_title'] = array(
      '#markup' => t('<br><br><div id="download_metadata_xml_file"><b>b) Download the Module XML metadata and upload it on your Identity Provider : </b>
                        <span><a href="' . $base_url . '/saml_metadata?download=true" class="mo_btn mo_btn-danger">Download XML Metadata</a></span></div>
                        <br><br><div><b>c) Provide the following information to your Identity Provider. Copy it and keep it handy.</b></div><br>'),
    );
    $copy_image = '<img class ="fa fa-fw fa-pull-right fa-lg fa-copy mo_copy" src="' . $base_url . '/' . $module_path . '/includes/images/copy-regular.svg">';
    $SP_Entity = [
      'data' => Markup::create('<span id="issuer_id">' . Utilities::getIssuer() . '</span>' . $copy_image),
    ];
    $SP_ACS = [
      'data' => Markup::create('<span id="login_url">' . $acs_url . '</span>' . $copy_image),
    ];
    $Audience = [
      'data' => Markup::create('<span id="audience_url">' . $base_url . '</span>' . $copy_image),
    ];
    $X_509_certificate = [
      'data' => Markup::create('Available in </b><a href="' . $base_url . MiniorangeSAMLConstants::LICENSING_TAB_URL . '">Standard, Premium and Enterprise</a> version.'),
    ];
    $Recipient = [
      'data' => Markup::create('<span id="recipientURL">' . $acs_url . '</span>' . $copy_image),
    ];
    $Destination = [
      'data' => Markup::create('<span id="destinationURL">' . $acs_url . '</span>' . $copy_image),
    ];
    $SingleLogoutURL = [
      'data' => Markup::create('Available in </b><a href="' . $base_url . MiniorangeSAMLConstants::LICENSING_TAB_URL . '">Premium and Enterprise</a> version.'),
    ];
    $NameIDFormat = [
      'data' => Markup::create('urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'),
    ];
    $mo_table_content = array(
      array(
        'SP Entity ID/Issuer',
        $SP_Entity,
      ),
      array(
        'SP ACS URL',
        $SP_ACS,
      ),
      array(
        'Audience URI',
        $Audience,
      ),
      array(
        'X.509 Certificate',
        $X_509_certificate,
      ),
      array(
        'Recipient URL',
        $Recipient,
      ),
      array(
        'Destination URL',
        $Destination,
      ),
      array(
        'Single Logout URL',
        $SingleLogoutURL,
      ),
      array(
        'NameID Format',
        $NameIDFormat,
      ),
    );
    $form['mo_saml_service_provider_metadata']['mo_saml_attrs_list_idp'] = array(
      '#type' => 'table',
      '#header' => array(
        'ATTRIBUTE',
        'VALUE',
      ),
      '#rows' => $mo_table_content,
      '#empty' => t('Something is not right. Please run the update script or contact us at <a href="' . MiniorangeSAMLConstants::SUPPORT_EMAIL . '">' . MiniorangeSAMLConstants::SUPPORT_EMAIL . '</a>'),
      '#responsive' => TRUE,
      '#sticky' => TRUE,
      '#size' => 2,
    );
    $form['mo_saml_service_provider_metadata']['miniorange_saml_update_url_note'] = array(
      '#markup' => t('<br><hr><br><div class="mo_saml_highlight_background_note_1"><strong>Note: </strong> If you have already shared the below URLs or Metadata with your IdP, <strong>DO NOT UPDATE</strong> SP EntityID. It might break your existing login flow.
                         Available in the <a href="' . $base_url . MiniorangeSAMLConstants::LICENSING_TAB_URL . '">Standard, Premium and Enterprise</a> version.   </div><br>'),
    );
    $form['mo_saml_service_provider_metadata']['miniorange_saml_base_url'] = array(
      '#type' => 'textfield',
      '#title' => t('SP Base URL:'),
      '#default_value' => Utilities::getBaseUrl(),
      '#attributes' => array(
        'style' => 'width:70%',
      ),
    );
    $form['mo_saml_service_provider_metadata']['miniorange_saml_entity_id'] = array(
      '#type' => 'textfield',
      '#title' => t('SP Entity ID/Issuer:'),
      '#default_value' => Utilities::getIssuer(),
      '#attributes' => array(
        'style' => 'width:70%',
      ),
    );
    $form['mo_saml_service_provider_metadata']['miniorange_saml_idp_config_submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update'),
      '#button_type' => 'primary',
      '#prefix' => '<br>',
      '#suffix' => '<br></div>',
    );
    Utilities::spConfigGuide($form, $form_state);
    return $form;
  }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_values = $form_state
      ->getValues();
    $b_url = $form_values['miniorange_saml_base_url'];
    $issuer_id = $form_values['miniorange_saml_entity_id'];
    \Drupal::configFactory()
      ->getEditable('miniorange_saml.settings')
      ->set('miniorange_saml_base_url', $b_url)
      ->save();
    \Drupal::configFactory()
      ->getEditable('miniorange_saml.settings')
      ->set('miniorange_saml_entity_id', $issuer_id)
      ->save();
    \Drupal::messenger()
      ->addStatus(t('Base URL and/or Issuer updated successfully.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 87
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.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
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.
MiniorangeIDPSetup::buildForm public function Form constructor. Overrides FormInterface::buildForm
MiniorangeIDPSetup::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
MiniorangeIDPSetup::submitForm public function Form submission handler. Overrides FormInterface::submitForm
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.