You are here

public function SamlService::__construct in SAML Authentication 4.x

Same name and namespace in other branches
  1. 8.3 src/SamlService.php \Drupal\samlauth\SamlService::__construct()
  2. 8 src/SamlService.php \Drupal\samlauth\SamlService::__construct()
  3. 8.2 src/SamlService.php \Drupal\samlauth\SamlService::__construct()

Constructs a new SamlService.

Parameters

\Drupal\externalauth\ExternalAuth $external_auth: The ExternalAuth service.

\Drupal\externalauth\Authmap $authmap: The Authmap service.

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: The config factory.

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The EntityTypeManager service.

\Psr\Log\LoggerInterface $logger: A logger instance.

\Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher: The event dispatcher.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

\Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory: A temp data store factory object.

\Drupal\Core\Flood\FloodInterface $flood: The flood service.

\Drupal\Core\Session\AccountInterface $current_user: The current user service.

\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger service.

\Drupal\Core\StringTranslation\TranslationInterface $translation: The string translation service.

File

src/SamlService.php, line 166

Class

SamlService
Governs communication between the SAML toolkit and the IdP / login behavior.

Namespace

Drupal\samlauth

Code

public function __construct(ExternalAuth $external_auth, Authmap $authmap, ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, LoggerInterface $logger, EventDispatcherInterface $event_dispatcher, RequestStack $request_stack, PrivateTempStoreFactory $temp_store_factory, FloodInterface $flood, AccountInterface $current_user, MessengerInterface $messenger, TranslationInterface $translation) {
  $this->externalAuth = $external_auth;
  $this->authmap = $authmap;
  $this->configFactory = $config_factory;
  $this->entityTypeManager = $entity_type_manager;
  $this->logger = $logger;
  $this->eventDispatcher = $event_dispatcher;
  $this->requestStack = $request_stack;
  $this->privateTempStore = $temp_store_factory
    ->get('samlauth');
  $this->flood = $flood;
  $this->currentUser = $current_user;
  $this->messenger = $messenger;
  $this
    ->setStringTranslation($translation);
  $config = $this->configFactory
    ->get('samlauth.authentication');

  // setProxyVars lets the SAML PHP Toolkit use 'X-Forwarded-*' HTTP headers
  // for identifying the SP URL, but we should pass the Drupal/Symfony base
  // URL to into the toolkit instead. That uses headers/trusted values in the
  // same way as the rest of Drupal (as configured in settings.php).
  // @todo remove this in v4.x
  if ($config
    ->get('use_proxy_headers') && !$config
    ->get('use_base_url')) {

    // Use 'X-Forwarded-*' HTTP headers for identifying the SP URL.
    SamlUtils::setProxyVars(TRUE);
  }
}