You are here

class WindowsAadSSORouteSubscriber in OpenID Connect Microsoft Azure Active Directory client 8

Same name and namespace in other branches
  1. 2.0.x src/Routing/WindowsAadSSORouteSubscriber.php \Drupal\openid_connect_windows_aad\Routing\WindowsAadSSORouteSubscriber

Listens to the dynamic route events.

Hierarchy

Expanded class hierarchy of WindowsAadSSORouteSubscriber

1 string reference to 'WindowsAadSSORouteSubscriber'
openid_connect_windows_aad.services.yml in ./openid_connect_windows_aad.services.yml
openid_connect_windows_aad.services.yml
1 service uses WindowsAadSSORouteSubscriber
openid_connect_windows_aad.route_subscriber in ./openid_connect_windows_aad.services.yml
\Drupal\openid_connect_windows_aad\Routing\WindowsAadSSORouteSubscriber

File

src/Routing/WindowsAadSSORouteSubscriber.php, line 12

Namespace

Drupal\openid_connect_windows_aad\Routing
View source
class WindowsAadSSORouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection
      ->get('user.logout')) {
      try {
        $configuration = \Drupal::config('openid_connect.settings.windows_aad');
        $settings = $configuration
          ->get('settings');
        $enabled = $configuration
          ->get('enabled');
      } catch (Exception $exception) {

        // Not important to differentiate between Exceptions here, we just need
        // make it know that something is wrong and we won't enable SSOut.
        $configuration = FALSE;

        // TODO: When watchdog_exception() is deprecated and ExceptionLogger is
        // available, update this to use ExceptionLogger.
        // @see https://www.drupal.org/project/drupal/issues/2932518
        $variables = Error::decodeException($exception);
        \Drupal::logger('openid_connect_windows_aad')
          ->error('Failed to check OpenID Connect Windows AAD configuration so Single Sign Off will remain disabled. %type: @message in %function (line %line of %file).', $variables);
      }

      // Override the controller for the user.logout route in order to redirect
      // to the Windows Azure AD Single Sign out endpoint if SSOut is enabled.
      if ($configuration && $enabled && isset($settings['enable_single_sign_out']) && $settings['enable_single_sign_out']) {
        $route
          ->setDefault('_controller', '\\Drupal\\openid_connect_windows_aad\\Controller\\WindowsAadSSOController::logout');
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1
WindowsAadSSORouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes