You are here

public function SamlController::login in SAML Authentication 8.3

Same name and namespace in other branches
  1. 8 src/Controller/SamlController.php \Drupal\samlauth\Controller\SamlController::login()
  2. 8.2 src/Controller/SamlController.php \Drupal\samlauth\Controller\SamlController::login()
  3. 4.x src/Controller/SamlController.php \Drupal\samlauth\Controller\SamlController::login()

Initiates a SAML2 authentication flow.

This route does not log us in (yet); it should redirect to the Login service on the IdP, which should be redirecting back to our ACS endpoint after authenticating the user.

Return value

\Drupal\Core\Routing\TrustedRedirectResponse The HTTP response to send back.

1 string reference to 'SamlController::login'
samlauth.routing.yml in ./samlauth.routing.yml
samlauth.routing.yml

File

src/Controller/SamlController.php, line 143

Class

SamlController
Returns responses for samlauth module routes.

Namespace

Drupal\samlauth\Controller

Code

public function login() {

  // $function returns a string and supposedly never calls 'external' Drupal
  // code... so it wouldn't need to be executed inside a render context. The
  // standard exception handling does, though.
  $function = function () {
    return $this->saml
      ->login($this
      ->getUrlFromDestination());
  };

  // This response redirects to an external URL in all/common cases. We count
  // on the routing.yml to specify that it's not cacheable.
  return $this
    ->getShortenedRedirectResponse($function, 'initiating SAML login', '<front>');
}