You are here

public function SamlController::logout in SAML Authentication 4.x

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

Initiates a SAML2 logout flow.

According to the SAML spec, this route does not log us out (yet); it should redirect to the SLS service on the IdP, which should be redirecting back to our SLS endpoint (possibly first logging out from other systems first). We do usually log out before redirecting, though.

Return value

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

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

File

src/Controller/SamlController.php, line 166

Class

SamlController
Returns responses for samlauth module routes.

Namespace

Drupal\samlauth\Controller

Code

public function logout() {

  // $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
      ->logout($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 logout', '<front>');
}