protected function SamlController::getShortenedRedirectResponse in SAML Authentication 8.3
Same name and namespace in other branches
- 4.x src/Controller/SamlController.php \Drupal\samlauth\Controller\SamlController::getShortenedRedirectResponse()
Gets a redirect response and modifies it a bit.
Split off from getTrustedRedirectResponse() because that's in a trait.
Parameters
callable $callable: Callable.
string $while: Description of when we're doing this, for error logging.
string $redirect_route_on_exception: Drupal route name to redirect to on exception.
3 calls to SamlController::getShortenedRedirectResponse()
- SamlController::login in src/
Controller/ SamlController.php - Initiates a SAML2 authentication flow.
- SamlController::logout in src/
Controller/ SamlController.php - Initiates a SAML2 logout flow.
- SamlController::sls in src/
Controller/ SamlController.php - Performs the Single Logout Service.
File
- src/
Controller/ SamlController.php, line 429
Class
- SamlController
- Returns responses for samlauth module routes.
Namespace
Drupal\samlauth\ControllerCode
protected function getShortenedRedirectResponse(callable $callable, $while, $redirect_route_on_exception) {
$response = $this
->getTrustedRedirectResponse($callable, $while, $redirect_route_on_exception);
// Symfony RedirectResponses set a HTML document as content, which is going
// to be ugly with our long URLs. Almost noone sees this content for a
// HTTP redirect, but still: overwrite it with a similar HTML document that
// doesn't include the URL parameter blurb in the rendered parts.
$url = $response
->getTargetUrl();
$pos = strpos($url, '?');
$shortened_url = $pos ? substr($url, 0, $pos) : $url;
// Almost literal copy from RedirectResponse::setTargetUrl():
$response
->setContent(sprintf('<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url=%1$s" />
<title>Redirecting to %2$s</title>
</head>
<body>
Redirecting to <a href="%1$s">%2$s</a>.
</body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'), $shortened_url));
return $response;
}