From 0469e81d2accb310bd596bbf5b18f97c84096200 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tim.dijen@minbzk.nl> Date: Wed, 28 Aug 2019 21:08:06 +0200 Subject: [PATCH] Fix raw template being returned by SingleLogoutResponse.php (#1192) * Force template to be rendered by Twig --- lib/SimpleSAML/IdP/IFrameLogoutHandler.php | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index 58374cf69..7abe0c192 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -96,16 +96,35 @@ class IFrameLogoutHandler implements LogoutHandlerInterface { assert(is_string($assocId)); - $config = Configuration::getInstance(); $this->idp->terminateAssociation($assocId); + $config = Configuration::getInstance(); + $usenewui = $config->getBoolean('usenewui', false); + + // Force the use of Twig for this method. Remove if-clause in 2.0 + if ($usenewui === false) { + $config = Configuration::loadFromArray([ + 'usenewui' => true, + ]); + } + $t = new Template($config, 'IFrameLogoutHandler.twig'); $t->data['assocId'] = var_export($assocId, true); $t->data['spId'] = sha1($assocId); if (!is_null($error)) { $t->data['errorMsg'] = $error->getMessage(); } - $t->show(); - exit(0); + + // Remove the if-clause in 2.0, leave the else-part + if ($usenewui === false) { + $twig = $t->getTwig(); + if (!isset($twig)) { + throw new \Exception('Even though we explicitly configure that we want Twig, the Template class does not give us Twig. This is a bug.'); + } + $result = $twig->render('IFrameLogoutHandler.twig', $t->data); + echo $result; + } else { + $t->show(); + } } } -- GitLab