From 59e1dd5fd1a51e8d0808a26c34b2016ded44e6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Pe=CC=81rez=20Crespo?= <jaime.perez@uninett.no> Date: Thu, 29 Aug 2019 12:18:25 +0200 Subject: [PATCH] Create a PHP template for IFrameLogoutHandler This was inline in the script, and later migrated to a twig template. This made us force the use of twig, or otherwise the template would not work for the old user interface. We shouldn't do that, and we should have a proper PHP template in place. --- lib/SimpleSAML/IdP/IFrameLogoutHandler.php | 22 ++-------------------- templates/IFrameLogoutHandler.tpl.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 20 deletions(-) create mode 100644 templates/IFrameLogoutHandler.tpl.php diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index 7abe0c192..2597fdbab 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -99,32 +99,14 @@ class IFrameLogoutHandler implements LogoutHandlerInterface $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 = new Template($config, 'IFrameLogoutHandler.tpl.php'); $t->data['assocId'] = var_export($assocId, true); $t->data['spId'] = sha1($assocId); if (!is_null($error)) { $t->data['errorMsg'] = $error->getMessage(); } - // 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(); - } + $t->show(); } } diff --git a/templates/IFrameLogoutHandler.tpl.php b/templates/IFrameLogoutHandler.tpl.php new file mode 100644 index 000000000..2a38f4bb8 --- /dev/null +++ b/templates/IFrameLogoutHandler.tpl.php @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html> + <head> + <title>Logout response from <?= htmlspecialchars(var_export($this->data['assocId'])); ?></title> + <script> +<?php + if (array_key_exists('errorMsg', $this->data)) { + echo 'window.parent.logoutFailed("'.$this->data['spId'].'", "'.addslashes($this->data['errorMsg']).'");'; + } else { + echo 'window.parent.logoutCompleted("'.$this->data['spId'].'");'; + } +?> + </script> + </head> + <body></body> +</html> -- GitLab