You are here

public function InitSubscriber::onEvent in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

File

src/EventSubscriber/InitSubscriber.php, line 21
Contains \Drupal\miniorange_saml\EventSubscriber\InitSubscriber.

Class

InitSubscriber

Namespace

Drupal\miniorange_saml\EventSubscriber

Code

public function onEvent() {
  global $base_url;
  $relay_state = $base_url . '/' . Url::fromRoute("<current>")
    ->toString();
  $force_auth = \Drupal::config('miniorange_saml.settings')
    ->get('miniorange_saml_force_auth');
  $enable_saml_login = \Drupal::config('miniorange_saml.settings')
    ->get('miniorange_saml_enable_login');
  if ($enable_saml_login) {
    if ($force_auth && !\Drupal::currentUser()
      ->isAuthenticated()) {
      saml_login($relay_state);
    }
  }
}