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

Large update to discojuice module. Now making use of discojuice.org

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2970 44740490-163a-0410-bde0-09ae8108e29a
parent 33e72c57
No related branches found
No related tags found
No related merge requests found
Showing
with 118 additions and 345 deletions
<?php
/**
* This is the configuration file for the DiscoJuice.
*/
$config = array(
// A human readable name describing the Service Provider
'name' => 'Service',
/* A set of prepared metadata feeds from discojuice.org
* You may visit
* https://static.discojuice.org/feeds/
*
* to review the available feed identifiers.
* You may choose to not use any of the provider feed, by setting this to an
* empty array: array()
*/
'feeds' => array('edugain'),
/*
* You may provide additional feeds
*/
'additionalFeeds' => array(
),
/*
* If you set this value to true, the module will contact discojuice.org to read and write cookies.
* If you enable this, you will also need to get your host accepted in the access control list of
* discojuice.org
*
* The response url of your service, similar to:
*
* https://sp.example.org/simplesaml/module.php/discojuice/response.html
*
* will need to be registered at discojuice.org. If your response url is already registered in the metadata
* of one of the federation feeds at discojuice.org, you should already have access.
*/
'enableCentralStorage' => false,
);
\ No newline at end of file
<?php
/**
* This is a DiscoJuice configuration file.
*
* This configuration is used for the standalone DiscoJuice instance, that will become available at:
* /simplesaml/module.php/discojuice/central.php
*
* For details about the configuration option visit the DiscoJuice documentation:
* http://discojuice.simplesamlphp.org/docs
*/
$config = array(
// Which hostnames should be allowed to read user selections on entities chosen using DiscoJuice.
// You need to enable those hostnames that is configured to read data using the DiscoJuiceReadWrite protocol.
// http://discojuice.simplesamlphp.org/docs/1.0/discoreadwrite
'acl' => array(
'simplesamlphp.org', 'example.org',
),
// DiscoJuice opitions for the central DiscoJuice page.
'discojuice.options' => array(
"title"=> 'Sign in to <strong>this service</strong>',
"subtitle"=> "Select your Provider",
"always"=> true,
"overlay"=> true,
"cookie"=> true,
"type"=> false,
"country"=> true,
"location"=> true,
"debug.weight" => false,
),
);
\ No newline at end of file
<?php
/**
* This is a DiscoJuice configuration file.
*
* This configuration is used for the embedded DiscoJuice instance.
*
* For details about the configuration option visit the DiscoJuice documentation:
* http://discojuice.simplesamlphp.org/docs
*/
$config = array(
'target' => 'a.signin',
'discojuice.options' => array(
"title"=> 'Sign in to <strong>Foodle</strong>',
"subtitle"=> "Select your Provider",
// Want to override the inline help texts in DiscoJuice, uncomment the following section:
/*
'textSearch' => 'søk etter noe...',
'textHelp' => 'Finner du ikke en innnloggsingstjener du kjenner?',
'textHelpMore' => 'Let mer...',
*/
// Where to fetch metadata from. DiscoJuiceJSON format..
// You may provide a 'callback=?' querystring parameter in ordert to support JSONP.
// By default this feed endpoint is automatically configured to be correct for the
// DiscoJuice simpleSAMLphp module (which has a built-in feed generator).
// "metadata" => 'http://example.org/discojuicejson/index.php?callback=?',
"always"=> false,
"overlay"=> true,
"cookie"=> true,
"type"=> false,
"country"=> true,
"location"=> true,
"debug.weight" => false,
),
"callback" => "
function(e) {
// The auth parameter is indicating which authentication method is being used.
var auth = e.auth || null;
var returnto = window.location.href || 'https://example.org';
window.location = 'https://foodl.org/simplesaml/module.php/core/as_login.php?AuthId=saml&ReturnTo=' + escape(returnto) + '&saml:idp=' + escape(e.entityID);
}
"
);
\ No newline at end of file
<?php
/**
* This is a DiscoJuice configuration file.
*
* This configuration is used for the DiscoJuiceJSON metadata feed, that will become available at:
* /simplesaml/module.php/discojuice/feed.php
*
* For details about the configuration option visit the DiscoJuice documentation:
* http://discojuice.simplesamlphp.org/docs
*/
$config = array(
// Provides a list of IdPs that has already successfully logged in at least one user.
// Will give these IdPs extra weight in the UI.
// 'idplistapi' => 'https://foodl.org/api/idplist',
// Merge DiscoJuiceJSON with a additional sources.
// 'mergeEndpoints' => array(
// ),
// Include a set of extra entities, that is not present in metadata (DiscoJuiceJSON)
'insert' => array(
),
// Exclude a set of entity IDs to not show in the Discovery Service
'exclude' => array(
),
// Allows you to override DiscoJuiceJSON metadata.
// May be useful if an external party offers a DiscoJuiceJSON feed, and you would like to do some customization.
'overrides' => array(
),
);
\ No newline at end of file
......@@ -6,8 +6,7 @@
class sspmod_discojuice_CentralHelper {
public static function show($path = '/simplesaml/module.php/discojuice/discojuice/') {
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicecentral.php');
$config = SimpleSAML_Configuration::getInstance();
......@@ -15,7 +14,6 @@ class sspmod_discojuice_CentralHelper {
$feed = new sspmod_discojuice_Feed();
$metadata = json_decode($feed->read(), TRUE);
$t = new SimpleSAML_XHTML_Template($config, 'discojuice:central.tpl.php');
$t->data['metadata'] = $metadata;
$t->data['discojuice.options'] = $djconfig->getValue('discojuice.options');
......@@ -23,14 +21,7 @@ class sspmod_discojuice_CentralHelper {
$t->data['acl'] = $djconfig->getValue('acl');
$t->show();
}
}
<?php
$version = '0.1-4';
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
?><!DOCTYPE html>
<html lang="en">
<head>
......@@ -13,34 +9,18 @@ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT
<title>Select Your Login Provider</title>
<?php
echo '<link rel="shortcut icon" href="' . SimpleSAML_Module::getModuleURL('discojuice/favicon.png') . '" />
';
echo '<!-- JQuery -->';
echo '<script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-1.6.min.js') . '"></script>
<!-- script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-ui-1.8.5.custom.min.js') . '"></script -->
<!-- link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/custom/jquery-ui-1.8.5.custom.css') . '" / -->
';
<link rel="shortcut icon" href="http://discojuice.bridge.uninett.no/simplesaml/module.php/discojuice/favicon.png" />
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>
<script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.control.js?v=' . $version) . '"></script>
<!-- JQuery hosted by Google -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/idpdiscovery.js?v=' . $version) . '"></script>
<!-- DiscoJuice hosted by UNINETT at discojuice.org -->
<script type="text/javascript" src="https://engine.discojuice.org/discojuice-stable.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://static.discojuice.org/css/discojuice.css" />
<link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/discojuice.css?v=' . $version) . '" />';
?>
<style type="text/css">
body {
text-align: center;
}
......@@ -50,54 +30,46 @@ echo '<!-- DiscoJuice -->
width: 600px;
margin-right: auto;
margin-left: auto;
}
</style>
<script type="text/javascript">
<?php
global $options;
global $returnidparam, $returnto;
$options = $this->data['discojuice.options'];
<?php
if (!empty($_REQUEST['entityID'])) {
if (!array_key_exists('disco', $options)) {
$options['disco'] = array();
echo '
$("document").ready(function() {
var djc = DiscoJuice.Hosted.getConfig(' .
json_encode($this->data['hostedConfig'][0]) . "," .
json_encode($this->data['hostedConfig'][1]) . "," .
json_encode($this->data['hostedConfig'][2]) . "," .
json_encode($this->data['hostedConfig'][3]) . "," .
json_encode($this->data['hostedConfig'][4]) .
');';
echo " djc.country = false;\n";
echo " djc.showLocationInfo = false;\n";
if (!$this->data['enableCentralStorage']) {
echo " delete djc.disco;\n";
}
if (!empty($this->data['additionalFeeds'])) {
foreach($this->data['additionalFeeds'] AS $feed) {
echo " djc.metadata.push(" . json_encode($feed) . ");\n";
}
}
$options['disco']['spentityid'] = $_REQUEST['entityID'];
}
echo 'var options = ' . json_encode($options) . ';' . "\n\n";
echo 'options.countryAPI = "' . SimpleSAML_Module::getModuleURL('discojuice/country.php'). '"; ' . "\n";
if (empty($options['metadata'])) {
echo 'options.metadata = "' . SimpleSAML_Module::getModuleURL('discojuice/feed.php'). '"; ' . "\n";
}
if (!empty($options['disco'])) {
echo 'options.disco.url = "' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuiceDiscoveryResponse.html?'). '"; ' . "\n";
}
if (empty($options['discoPath'])) {
echo 'options.discoPath = "discojuice/"; ' . "\n";
$options['discoPath'] = "discojuice/";
}
echo " djc.always = true;\n";
echo '
$("a.signin").DiscoJuice(djc);
});
';
?>
echo 'var acl = ' . json_encode($this->data['acl']) . ';' . "\n";
echo 'acl.push("' . SimpleSAML_Utilities::getSelfHost() . '");' . "\n\n";
SimpleSAML_Logger::info('Icon URL is: ' . $options['discoPath'] );
?>
IdPDiscovery.setup(options, acl);
</script>
......@@ -105,99 +77,9 @@ SimpleSAML_Logger::info('Icon URL is: ' . $options['discoPath'] );
</head>
<body style="background: #ccc">
<p style="text-align: right"><a class="signin" href="/"></a></p>
<div class="noscript">
<?php
$metadata = $this->data['metadata'];
function cmp($a, $b) {
$xa = isset($a['weight']) ? $a['weight'] : 0;
$xb = isset($b['weight']) ? $b['weight'] : 0;
return ($xa-$xb);
}
usort($metadata, 'cmp');
<p style="display: none; text-align: right"><a class="signin" href="/">signin</a></p>
$spentityid = !empty($_REQUEST['entityID']) ? $_REQUEST['entityID'] : null;
$returnidparam = !empty($_REQUEST['returnIDParam']) ? $_REQUEST['returnIDParam'] : 'entityID';
$returnto = !empty($_REQUEST['return']) ? $_REQUEST['return'] : null;
function show($item) {
global $returnidparam, $returnto;
global $options;
$iconPath = $options['discoPath'] . 'logos/';
if (empty($item['entityID'])) {
SimpleSAML_Logger::warning('Missing entityID on item to show in central discovery service...');
return;
}
$href = $returnto . '&' . $returnidparam . '=' . urlencode($item['entityID']);
if (!empty($item['icon'])) {
echo '<a href="' . htmlspecialchars($href) . '" class="">' .
'<img src="' . htmlspecialchars($iconPath . $item['icon']) . '" />' .
'<span class="title">' . htmlspecialchars($item['title']) . '</span>' .
'<span class="substring">' . (!empty($item['descr']) ? htmlspecialchars($item['descr']) : '') . '</span>' .
'<hr style="clear: both; height: 0px; visibility:hidden" /></a>';
} else {
echo '<a href="' . htmlspecialchars($href) . '" class="">' .
'<span class="title">' . htmlspecialchars($item['title']) . '</span>' .
'<span class="substring">' . (!empty($item['descr']) ? htmlspecialchars($item['descr']) : '') . '</span></a>';
}
}
echo '<div style="display: block" class="discojuice">
<div class="top">
<a href="#" class="discojuice_close">&nbsp;</a>
<p class="discojuice_maintitle">Sign in</p>
<p class="discojuice_subtitle">Select your login provider</p>
</div>
<div id="content" style="">
<p class="moretext"></p>
<div class="scroller">';
foreach($metadata AS $item) {
show($item);
}
echo '</div>
</div>
<div class="filters bottom">
<p>You have disabled Javascript in your browser &mdash; therefore there user interface for selecting your provider is
lacking some features. You may still use browser inline search to easier locate your provider on the list.</p>
</div>
</div>';
?>
</div>
</body>
</html>
<?php
if (empty($_REQUEST['entityID'])) throw new Exception('Missing parameter [entityID]');
if (empty($_REQUEST['return'])) throw new Exception('Missing parameter [return]');
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicecentral.php');
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuice.php');
$config = SimpleSAML_Configuration::getInstance();
......@@ -9,11 +13,42 @@ $feed = new sspmod_discojuice_Feed();
$metadata = json_decode($feed->read(), TRUE);
// EntityID
$entityid = $_REQUEST['entityID'];
// Return to...
$returnidparam = !empty($_REQUEST['returnIDParam']) ? $_REQUEST['returnIDParam'] : 'entityID';
$href = SimpleSAML_Utilities::addURLparameter(
$_REQUEST['return'],
array($returnidparam => '')
);
$hostedConfig = array(
// Name of service
$djconfig->getString('name', 'Service'),
$entityid,
// Url to response
SimpleSAML_Module::getModuleURL('discojuice/response.html'),
// Set of feeds to subscribe to.
$djconfig->getArray('feeds', 'Service'),
$href
);
/*
"a.signin", "Teest Demooo",
"https://example.org/saml2/entityid",
"' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuiceDiscoveryResponse.html') . '", ["kalmar"], "http://example.org/login?idp="
*/
$t = new SimpleSAML_XHTML_Template($config, 'discojuice:central.tpl.php');
$t->data['metadata'] = $metadata;
$t->data['discojuice.options'] = $djconfig->getValue('discojuice.options');
$t->data['acl'] = $djconfig->getValue('acl');
$t->data['hostedConfig'] = $hostedConfig;
$t->data['enableCentralStorage'] = $djconfig->getBoolean('enableCentralStorage', true);
$t->data['additionalFeeds'] = $djconfig->getArray('additionalFeeds', null);
$t->show();
......
<?php
//sleep(3);
try {
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicecentral.php');
$options = $djconfig->getConfigItem('discojuice.options');
$enableCountryAPI = $options->getValue('country', FALSE);
if ($enableCountryAPI !== TRUE) {
throw new Exception('Use of the DiscoJuice Country API is disabled.');
}
$result = array('status' => 'ok');
$c = new sspmod_discojuice_Country();
$region = $c->getRegion();
if (preg_match('|^(.*?)/(.*?)$|', $region, $matches)) {
if (!empty($matches[1])) $result['country'] = $matches[1];
if (!empty($matches[2])) $result['region'] = $matches[2];
}
$geo = $c->getGeo();
if (preg_match('|^(.*?),(.*?)$|', $geo, $matches)) {
$result['geo'] = array('lat' => (float) $matches[1], 'lon' => (float)$matches[2]);
}
if(preg_match('/^[0-9A-Za-z_\-]+$/', $_REQUEST['callback'], $matches)) {
header('Content-type: application/javascript; utf-8');
echo $_REQUEST['callback'] . '(' . json_encode($result) . ');';
} else {
header('Content-type: application/json; utf-8');
echo json_encode($result);
}
} catch(Exception $e) {
echo json_encode(array('status' => 'error', 'error' => $e->getMessage()));
}
modules/discojuice/www/discojuice/css/custom/images/ui-icons_222222_256x240.png

4.27 KiB

modules/discojuice/www/discojuice/css/custom/images/ui-icons_2e83ff_256x240.png

4.27 KiB

modules/discojuice/www/discojuice/css/custom/images/ui-icons_454545_256x240.png

4.27 KiB

modules/discojuice/www/discojuice/css/custom/images/ui-icons_888888_256x240.png

4.27 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment