public function SimplesamlSubscriber::login_directly_with_external_IdP in simpleSAMLphp Authentication 8.3
Redirect anonymous users to the external IdP from the Drupal login page.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The subscribed event.
File
- src/
EventSubscriber/ SimplesamlSubscriber.php, line 127
Class
- SimplesamlSubscriber
- Event subscriber subscribing to KernelEvents::REQUEST.
Namespace
Drupal\simplesamlphp_auth\EventSubscriberCode
public function login_directly_with_external_IdP(GetResponseEvent $event) {
if ($this->config
->get('allow.default_login')) {
return;
}
// Check if an anonymous user tries to access the Drupal login page.
if ($this->account
->isAnonymous() && $this->routeMatch
->getRouteName() == 'user.login') {
// Get the path (default: '/saml_login') from the
// 'simplesamlphp_auth.saml_login' route.
$saml_login_path = Url::fromRoute('simplesamlphp_auth.saml_login')
->toString();
// Redirect directly to the external IdP.
$response = new RedirectResponse($saml_login_path, RedirectResponse::HTTP_FOUND);
$event
->setResponse($response);
$event
->stopPropagation();
}
}