Skip to content
Snippets Groups Projects
Commit 2df662d7 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Improvements to IdP Discovery Service PRotocol [discojuice]

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2801 44740490-163a-0410-bde0-09ae8108e29a
parent a83acd7c
No related branches found
No related tags found
No related merge requests found
<?php
$version = '0.1';
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
?><!DOCTYPE html>
<html lang="en">
<head>
......@@ -25,7 +29,7 @@ echo '<script type="text/javascript" language="javascript" src="' . SimpleSAML_M
';
$version = '0.1';
echo '<!-- DiscoJuice -->
<script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.misc.js?v=' . $version ) . '"></script>
<script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.ui.js?v=' . $version) . '"></script>
......@@ -59,6 +63,11 @@ echo '<!-- DiscoJuice -->
global $options;
$options = $this->data['discojuice.options'];
// echo '<pre>opts';
// print_r($options);
// exit;
echo 'var options = ' . json_encode($options) . ';' . "\n\n";
echo 'options.countryAPI = "' . SimpleSAML_Module::getModuleURL('discojuice/country.php'). '"; ' . "\n";
......@@ -87,7 +96,6 @@ SimpleSAML_Logger::info('Icon URL is: ' . $options['discoPath'] );
?>
IdPDiscovery.receive();
IdPDiscovery.setup(options, acl);
</script>
......
......@@ -91,7 +91,8 @@ DiscoJuice.Control = {
}
},
"discoResponse": function(entityID) {
"discoResponse": function(entityID, sender) {
this.parent.Utils.log('DiscoResponse Received from [' + sender + ']');
this.setWeight(entityID, -100);
this.prepareData();
},
......
......@@ -2,10 +2,18 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<title>IdP Discovery Response Receiver</title>
<script type="text/javascript">
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return a.hostname;
}
function receive() {
var urlParams = {};
......@@ -20,10 +28,14 @@ function receive() {
urlParams[d(e[1])] = d(e[2]);
})();
var sender = parseURL(document.referrer);
if (urlParams.entityID) {
window.parent.DiscoJuice.Utils.log('Response from discovery service: ' + urlParams.entityID);
window.parent.DiscoJuice.Control.discoResponse(urlParams.entityID);
}
window.parent.DiscoJuice.Utils.log('ResponseLocation: Response from discovery service [' + sender + ']: ' + urlParams.entityID);
window.parent.DiscoJuice.Control.discoResponse(urlParams.entityID, sender);
} else {
window.parent.DiscoJuice.Utils.log('ResponseLocation: Response from discovery service [' + sender + ']: No valid response parameters');
}
}
</script>
......
......@@ -69,15 +69,18 @@ var IdPDiscovery = function() {
var returnToHost = this.getHostname(returnTo);
for (var i = 0; i < this.returnURLs.length; i++) {
if (this.returnURLs[i] == returnToHost) allowed = true;
// console.log('returnURLs2');
// console.log(returnURLs);
for (var i = 0; i < returnURLs.length; i++) {
if (returnURLs[i] == returnToHost) allowed = true;
}
if (!allowed) {
DiscoJuice.Utils.log('Access denied for return parameter [' + returnToHost + ']');
DiscoJuice.Utils.log('Allowed hosts');
DiscoJuice.Utils.log(this.returnURLs);
DiscoJuice.Utils.log(returnURLs);
return;
}
}
......@@ -87,8 +90,11 @@ var IdPDiscovery = function() {
}
if (!e.entityID) {
DiscoJuice.Utils.log('ReturnTo without Entityid');
DiscoJuice.Utils.log(e);
window.location = returnTo;
} else {
DiscoJuice.Utils.log('ReturnTo with Entityid');
window.location = returnTo + '&' + returnIDParam + '=' + escape(e.entityID);
}
......@@ -115,17 +121,24 @@ var IdPDiscovery = function() {
var isPassive = query.isPassive || 'false';
if (isPassive === 'true') {
this.returnTo(preferredIdP);
this.returnTo({'entityID': preferredIdP});
}
},
"setup": function(options, rurls) {
// console.log('Setting up DiscoJuice');
// console.log(rurls);
returnURLs = rurls;
this.receive();
this.startUI();
},
"setup": function(options, rurls) {
"startUI": function() {
var that = this;
this.returnURLs = rurls;
$(document).ready(function() {
var overthere = that;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment