Skip to content

Commit

Permalink
Do not enforce Twig on oldui
Browse files Browse the repository at this point in the history
Conflicts:
	lib/IdP/ADFS.php
  • Loading branch information
tvdijen committed Aug 29, 2019
1 parent 3207f4f commit 13ec2fd
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions lib/IdP/ADFS.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,30 @@ private static function signResponse($response, $key, $cert, $algo, $passphrase)
private static function postResponse($url, $wresult, $wctx)
{
$config = \SimpleSAML\Configuration::getInstance();
$newui = $config->getBoolean('usenewui', false);

// Remove this in SSP 2.0 when Twig has become the default
if ($newui === false) {
$config = \SimpleSAML\Configuration::loadFromArray(['usenewui' => true]);
}

$t = new \SimpleSAML\XHTML\Template($config, 'adfs:postResponse.twig');
$t->data['baseurlpath'] = \SimpleSAML\Module::getModuleURL('adfs');
$t->data['url'] = $url;
$t->data['wresult'] = $wresult;
$t->data['wctx'] = $wctx;

// Remove the IF-part in SSP 2.0 when Twig has become the default
if ($newui === 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('adfs:postResponse.twig', $t->data);
echo $result;
$usenewui = $config->getBoolean('usenewui', false);
if ($usenewui === false) {
$wresult = htmlspecialchars($wresult);
$wctx = htmlspecialchars($wctx);

$post = <<<MSG
<body onload="document.forms[0].submit()">
<form method="post" action="$url">
<input type="hidden" name="wa" value="wsignin1.0">
<input type="hidden" name="wresult" value="$wresult">
<input type="hidden" name="wctx" value="$wctx">
<noscript>
<input type="submit" value="Continue">
</noscript>
</form>
</body>
MSG;
echo $post;
} else {
$t = new \SimpleSAML\XHTML\Template($config, 'adfs:postResponse.twig');
$t->data['baseurlpath'] = \SimpleSAML\Module::getModuleURL('adfs');
$t->data['url'] = $url;
$t->data['wresult'] = $wresult;
$t->data['wctx'] = $wctx;
$t->show();
}
}
Expand Down

0 comments on commit 13ec2fd

Please sign in to comment.