Skip to content
Snippets Groups Projects
Commit e70c8271 authored by Olav Morken's avatar Olav Morken
Browse files

LogoutIFrame: Use POST data instead of cookies.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2658 44740490-163a-0410-bde0-09ae8108e29a
parent 585fe2e2
No related branches found
No related tags found
No related merge requests found
...@@ -60,12 +60,7 @@ class SimpleSAML_IdP_LogoutIFrame extends SimpleSAML_IdP_LogoutHandler { ...@@ -60,12 +60,7 @@ class SimpleSAML_IdP_LogoutIFrame extends SimpleSAML_IdP_LogoutHandler {
assert('is_string($assocId)'); assert('is_string($assocId)');
$spId = sha1($assocId); $spId = sha1($assocId);
$cookieId = 'logout-iframe-' . $spId; $this->idp->terminateAssociation($assocId);
$globalConfig = SimpleSAML_Configuration::getInstance();
$cookiePath = '/' . $globalConfig->getBaseURL();
setcookie($cookieId, ($error ? 'failed' : 'completed'), time() + 5*60, $cookiePath);
echo('<!DOCTYPE html> echo('<!DOCTYPE html>
<html> <html>
......
...@@ -158,7 +158,7 @@ if ($nFailed > 0) { ...@@ -158,7 +158,7 @@ if ($nFailed > 0) {
echo('<div id="logout-failed-message" style="margin-top: 1em; border: 1px solid #ccc; padding: 1em; background: #eaeaea;' . $displayStyle . '">'); echo('<div id="logout-failed-message" style="margin-top: 1em; border: 1px solid #ccc; padding: 1em; background: #eaeaea;' . $displayStyle . '">');
echo('<img src="/' . $this->data['baseurlpath'] . 'resources/icons/experience/gtk-dialog-warning.48x48.png" alt="" style="float: left; margin-right: 5px;" />'); echo('<img src="/' . $this->data['baseurlpath'] . 'resources/icons/experience/gtk-dialog-warning.48x48.png" alt="" style="float: left; margin-right: 5px;" />');
echo('<p>' . $this->t('{logout:failedsps}') . '</p>'); echo('<p>' . $this->t('{logout:failedsps}') . '</p>');
echo('<form method="get" action="logout-iframe-done.php" target="_top">'); echo('<form method="post" action="logout-iframe-done.php" id="failed-form" target="_top">');
echo('<input type="hidden" name="id" value="' . $id . '" />'); echo('<input type="hidden" name="id" value="' . $id . '" />');
echo('<input type="submit" name="continue" value="' . $this->t('{logout:return}'). '" />'); echo('<input type="submit" name="continue" value="' . $this->t('{logout:return}'). '" />');
echo('</form>'); echo('</form>');
...@@ -172,7 +172,7 @@ if ($nProgress == 0 && $nFailed == 0) { ...@@ -172,7 +172,7 @@ if ($nProgress == 0 && $nFailed == 0) {
} }
echo('<p>' . $this->t('{logout:success}') . '</p>'); echo('<p>' . $this->t('{logout:success}') . '</p>');
?> ?>
<form method="get" action="logout-iframe-done.php" id="done-form" target="_top"> <form method="post" action="logout-iframe-done.php" id="done-form" target="_top">
<input type="hidden" name="id" value="<?php echo $id; ?>" /> <input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="submit" name="continue" value="<?php echo $this->t('{logout:return}'); ?>" /> <input type="submit" name="continue" value="<?php echo $this->t('{logout:return}'); ?>" />
</form> </form>
......
...@@ -20,21 +20,16 @@ if (!isset($_REQUEST['cancel'])) { ...@@ -20,21 +20,16 @@ if (!isset($_REQUEST['cancel'])) {
$state['core:Failed'] = TRUE; /* Mark as partial logout. */ $state['core:Failed'] = TRUE; /* Mark as partial logout. */
} }
$globalConfig = SimpleSAML_Configuration::getInstance();
$cookiePath = '/' . $globalConfig->getBaseURL();
/* Find the status of all SPs. */ /* Find the status of all SPs. */
foreach ($SPs as $assocId => &$sp) { foreach ($SPs as $assocId => &$sp) {
$spId = sha1($assocId); $spId = 'logout-iframe-' . sha1($assocId);
$cookieId = 'logout-iframe-' . $spId; if (isset($_REQUEST[$spId])) {
if (isset($_COOKIE[$cookieId])) { $spStatus = $_REQUEST[$spId];
$cookie = $_COOKIE[$cookieId]; if ($spStatus === 'completed' || $spStatus === 'failed') {
if ($cookie == 'completed' || $cookie == 'failed') { $sp['core:Logout-IFrame:State'] = $spStatus;
$sp['core:Logout-IFrame:State'] = $cookie;
} }
setcookie($cookieId, '', time() - 3600, $cookiePath);
} }
if (!isset($associations[$assocId])) { if (!isset($associations[$assocId])) {
......
...@@ -32,6 +32,17 @@ function updateSPStatus(spId, status, reason) { ...@@ -32,6 +32,17 @@ function updateSPStatus(spId, status, reason) {
$('#statusimage-' + spId).attr('src', window.stateImage[status]).attr('alt', window.stateText[status]).attr('title', reason); $('#statusimage-' + spId).attr('src', window.stateImage[status]).attr('alt', window.stateText[status]).attr('title', reason);
window.spStatus[spId] = status; window.spStatus[spId] = status;
var formId = 'logout-iframe-' + spId;
var existing = $('input[name="' + formId + '"]');
if (existing.length == 0) {
/* Don't have an existing form element - add one. */
var elementHTML = '<input type="hidden" name="' + formId + '" value="' + status + '" />';
$('#failed-form , #done-form').append(elementHTML);
} else {
/* Update existing element. */
existing.attr('value', status);
}
updateStatus(); updateStatus();
} }
function logoutCompleted(spId) { function logoutCompleted(spId) {
...@@ -49,24 +60,9 @@ function timeoutSPs() { ...@@ -49,24 +60,9 @@ function timeoutSPs() {
} }
} }
function asyncUpdate() {
jQuery.getJSON(window.asyncURL, window.spStatus, function(data, textStatus) {
for (sp in data) {
if (data[sp] == 'completed') {
logoutCompleted(sp);
} else if (data[sp] == 'failed') {
logoutFailed(sp, 'async update');
}
}
window.setTimeout(asyncUpdate, 1000);
});
}
$('document').ready(function(){ $('document').ready(function(){
if (window.type == 'js') { if (window.type == 'js') {
window.timeoutID = window.setTimeout(timeoutSPs, window.timeoutIn * 1000); window.timeoutID = window.setTimeout(timeoutSPs, window.timeoutIn * 1000);
window.setTimeout(asyncUpdate, 1000);
updateStatus(); updateStatus();
} else if (window.type == 'init') { } else if (window.type == 'init') {
$('#logout-type-selector').attr('value', 'js'); $('#logout-type-selector').attr('value', 'js');
......
...@@ -7,7 +7,7 @@ $id = (string)$_REQUEST['id']; ...@@ -7,7 +7,7 @@ $id = (string)$_REQUEST['id'];
if (isset($_REQUEST['type'])) { if (isset($_REQUEST['type'])) {
$type = (string)$_REQUEST['type']; $type = (string)$_REQUEST['type'];
if (!in_array($type, array('init', 'js', 'nojs', 'embed', 'async'), TRUE)) { if (!in_array($type, array('init', 'js', 'nojs', 'embed'), TRUE)) {
throw new SimpleSAML_Error_BadRequest('Invalid value for type.'); throw new SimpleSAML_Error_BadRequest('Invalid value for type.');
} }
} else { } else {
...@@ -41,15 +41,6 @@ if ($type !== 'init') { ...@@ -41,15 +41,6 @@ if ($type !== 'init') {
$sp['core:Logout-IFrame:State'] = 'inprogress'; $sp['core:Logout-IFrame:State'] = 'inprogress';
} }
/* Check for update by cookie. */
$cookieId = 'logout-iframe-' . $spId;
if (isset($_COOKIE[$cookieId])) {
$cookie = $_COOKIE[$cookieId];
if ($cookie == 'completed' || $cookie == 'failed') {
$sp['core:Logout-IFrame:State'] = $cookie;
}
}
/* Check for update through request. */ /* Check for update through request. */
if (isset($_REQUEST[$spId])) { if (isset($_REQUEST[$spId])) {
$s = $_REQUEST[$spId]; $s = $_REQUEST[$spId];
...@@ -99,18 +90,6 @@ if ($type === 'nojs') { ...@@ -99,18 +90,6 @@ if ($type === 'nojs') {
$t->data['timeout'] = $timeout; $t->data['timeout'] = $timeout;
$t->show(); $t->show();
exit(0); exit(0);
} elseif ($type == 'async') {
header('Content-Type: application/json');
$res = array();
foreach ($state['core:Logout-IFrame:Associations'] as $assocId => $sp) {
if ($sp['core:Logout-IFrame:State'] !== 'completed') {
continue;
}
$res[sha1($assocId)] = 'completed';
}
echo(json_encode($res));
exit(0);
} }
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:logout-iframe.php'); $t = new SimpleSAML_XHTML_Template($globalConfig, 'core:logout-iframe.php');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment