diff --git a/database/2.6.2-2.6.3.sql b/database/2.6.2-2.6.3.sql new file mode 100644 index 0000000000000000000000000000000000000000..f5dbc8feb18b8ca3c606f6a1a5932bdbc5d4661e --- /dev/null +++ b/database/2.6.2-2.6.3.sql @@ -0,0 +1,5 @@ +# Run this when updating from version 2.6.2 to 2.6.3 + +ALTER TABLE `eccs_stat` ADD `update_date` DATE DEFAULT NULL; +ALTER TABLE `entity_details` ADD `eccs_status_date` DATE DEFAULT NULL; + diff --git a/database/edugain_schema.sql b/database/edugain_schema.sql index 311a7c747cf0dde4b1213d62e2df06592126d15c..e2f491f141e184a0ec03dab81f2ddf82e8448b70 100644 --- a/database/edugain_schema.sql +++ b/database/edugain_schema.sql @@ -80,6 +80,7 @@ DROP TABLE IF EXISTS `eccs_stat`; CREATE TABLE `eccs_stat` ( `entityid` char(255) COLLATE utf8_unicode_ci DEFAULT NULL, `status` int(1) DEFAULT NULL, + `update_date` DATE DEFAULT NULL,, UNIQUE KEY `entityid` (`entityid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -235,6 +236,7 @@ CREATE TABLE `entity_details` ( `roles` tinyint(4) DEFAULT NULL, `saml2_support` tinyint(4) DEFAULT '0', `eccs_status` int(1) DEFAULT '0', + `eccs_status_date` DATE DEFAULT NULL, `validator_status` bigint(20) DEFAULT NULL, `clash` int(1) DEFAULT '0', `coco_status` int(1) DEFAULT NULL, diff --git a/database/update_role_details.sql b/database/update_role_details.sql index d00f3936f93626ba11eb59964ca4a1ca86e35b5c..381f76255dcae45e82e0cd68482675210359a767 100644 --- a/database/update_role_details.sql +++ b/database/update_role_details.sql @@ -10,7 +10,7 @@ INSERT INTO entity_details (entity_id,saml2_support) select entity_id, max(saml2 INSERT INTO entity_details (entity_id, clash) select entity_id,count(code) FROM entity_duplication GROUP BY entity_id ON duplicate key UPDATE clash=values(clash); -UPDATE entity_details JOIN entities ON entity_details.entity_id=entities.id JOIN eccs_stat ON entities.entityid = eccs_stat.entityid set entity_details.eccs_status=eccs_stat.status; +UPDATE entity_details JOIN entities ON entity_details.entity_id=entities.id JOIN eccs_stat ON entities.entityid = eccs_stat.entityid set entity_details.eccs_status=eccs_stat.status, entity_details.eccs_status_date=eccs_stat.update_date; UPDATE entity_details JOIN entities ON entity_details.entity_id=entities.id JOIN coco_stat ON entities.entityid = coco_stat.entityid set entity_details.coco_status=coco_stat.status, entity_details.coco_id=coco_stat.coco_id; create temporary table entity_warn_tmp as (select entities.id as entity_id, BIT_OR(ifnull(1<<entity_role_warnings.warning_id,0))|BIT_OR(ifnull(1<<entity_warnings.warning_id,0)) as warn FROM entities LEFT JOIN entity_warnings ON entities.id=entity_warnings.entity_id LEFT JOIN entity_roles ON entity_roles.entity_id = entities.id LEFT JOIN entity_role_warnings ON entity_role_warnings.entityrole_id=entity_roles.id GROUP BY entities.id); diff --git a/lib/eduGAIN_entity.php b/lib/eduGAIN_entity.php index 1395e28180d33613ea372d09d3df03088b5e9615..a2d6677beeb591fa0fcc4f6e6d88bdd8bd3fc947 100644 --- a/lib/eduGAIN_entity.php +++ b/lib/eduGAIN_entity.php @@ -814,6 +814,7 @@ class eduGAIN_entity extends eduGAIN { case 'IDPSSODescriptor': $entity['role'][$roledesc]['type'] = 'IdP'; $entity['eccs_status'] = $R['eccs_status']; + $entity['eccs_status_date'] = $R['eccs_status_date']; break; case 'AttributeAuthorityDescriptor': $entity['role'][$roledesc]['type'] = 'AA'; @@ -945,7 +946,7 @@ class eduGAIN_entity extends eduGAIN { if ($V['type'] == 'IdP' && $entity['eccs_status'] != 0) { $td_s = "background:".Constants::ECCS_Colours[$entity['eccs_status']][1]."; text-align:center"; $a_s = "color:".Constants::ECCS_Colours[$entity['eccs_status']][0]; - $eccs = "<div class='status_box' style='$td_s'><a style='$a_s' href='javascript:show_eccs(\"" . urlencode($entity['entityid']) . "\")'>ECCS</a></div>"; + $eccs = "<div title='Status <b>".Constants::ECCS_Colours[$entity['eccs_status']][2]."</b> from test on ".$entity['eccs_status_date'].".<br> Click the link for more details.' class='eccs_status_box' style='$td_s'><a style='$a_s' href='javascript:show_eccs(\"" . urlencode($entity['entityid']) . "\", \"" . $entity['eccs_status_date'] . "\")'>ECCS</a></div>"; } else { $eccs = ''; } @@ -958,7 +959,7 @@ class eduGAIN_entity extends eduGAIN { $td_s = "background:red; text-align:center"; $a_s = "color:white"; } - $clash = "<div class='status_box' style='$td_s'><a class='clash' style='$a_s' href='javascript:show_clash(" . $entity['id'] . ")'>CLASH</a></div>"; + $clash = "<div class='clash_status_box' title='". $entity['id'] ."' style='$td_s'>CLASH</div>"; } else { $clash = ''; } @@ -1123,10 +1124,10 @@ class eduGAIN_entity extends eduGAIN { } switch ($sirtfi) { case 1 : - $search_filter .= " AND entity_details.sirtfi > 0"; + $search_filter .= " AND entity_details.sirtfi > 0"; // SIRTFI asserted break; case 2 : - $search_filter .= " AND entity_details.sirtfi = 2"; + $search_filter .= " AND entity_details.sirtfi = 2"; // SIRTFI errors break; default : break; @@ -1164,7 +1165,7 @@ class eduGAIN_entity extends eduGAIN { $search_filter .= " AND entity_history.status = 0 AND entity_history.first_seen <= '$endDate' AND entity_history.first_seen >= '$startDate'"; } - $q = "SELECT entities.id AS id,entities.entityid AS entityid,roles,regauth,entity_details.displayname AS e_displayname,entity_cat,roledesc,role_details.role_display_name as r_displayname, role_details.role_description AS r_description, role_details.role_service_name, entity_details.eccs_status AS eccs_status, entity_details.clash AS clash, entity_details.validator_status AS validator_status, entity_details.coco_status AS coco_status, entity_details.coco_id AS coco_id, entity_details.sirtfi AS sirtfi_status, mds_data.code AS code, role_details.scopes AS scopes, entity_history.first_seen AS first_seen FROM entities JOIN mds_data ON entities.regauth=mds_data.reg_auth LEFT JOIN entity_details ON entities.id=entity_details.entity_id LEFT JOIN role_details ON entities.id=role_details.entity_id $cat_join $search_filter ORDER BY entities.entityid,roledesc"; + $q = "SELECT entities.id AS id,entities.entityid AS entityid,roles,regauth,entity_details.displayname AS e_displayname,entity_cat,roledesc,role_details.role_display_name as r_displayname, role_details.role_description AS r_description, role_details.role_service_name, entity_details.eccs_status AS eccs_status, entity_details.eccs_status_date AS eccs_status_date, entity_details.clash AS clash, entity_details.validator_status AS validator_status, entity_details.coco_status AS coco_status, entity_details.coco_id AS coco_id, entity_details.sirtfi AS sirtfi_status, mds_data.code AS code, role_details.scopes AS scopes, entity_history.first_seen AS first_seen FROM entities JOIN mds_data ON entities.regauth=mds_data.reg_auth LEFT JOIN entity_details ON entities.id=entity_details.entity_id LEFT JOIN role_details ON entities.id=role_details.entity_id $cat_join $search_filter ORDER BY entities.entityid,roledesc"; Utils::debug(4, "database query: $q\n"); Utils::debug(4, "join: $cat_join\n"); Utils::debug(4, "filter:$search_filter\n"); diff --git a/scripts/ECCSinterface.php b/scripts/ECCSinterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a955f5cbdbbae21bccfabb2c97ef3e96cd5b9186 --- /dev/null +++ b/scripts/ECCSinterface.php @@ -0,0 +1,52 @@ +<?php +require "../lib/config.php"; +require(eduGAIN_config."eccs_update.php"); + + +class ECCSinterface { + public function __construct() { + $mysqli = new mysqli(DB_HOST, USER, PASSWORD, DB_DATABASE); + if ($mysqli->connect_error) + die("Not connected"); + $mysqli->set_charset('utf8'); + $this->mysqli = $mysqli; + } + + public function databaseQuery($q) { + $result = $this->mysqli->query($q); + if (!$result) { + error_log("database query problem: $q"); + die("database query problem"); + } + return($result); + } + + public function load_eccs() { + $j = file_get_contents(ECCS_URL.'/api/eccsresults?format=simple'); + $e = json_decode($j); + $Colors = [ + 'OK' => 1, + 'DISABLED' => 2, + 'ERROR' => 3, + 'UNKNOWN' => 4, + ]; + foreach ($e as $r) { + $this->ECCS[$r->entityID] = $Colors[$r->status]; + } + } + public $ECCS; +} + +$e = new ECCSinterface(); +$e->load_eccs(); +$date = gmdate("Y-m-d", time()); + +$q = "DELETE FROM eccs_stat"; +$e->databaseQuery($q); + +foreach ($e->ECCS as $e_id => $s) { + $q = "INSERT into eccs_stat (entityid,status,update_date) VALUES ('$e_id',$s, '$date') ON DUPLICATE KEY UPDATE status=$s, update_date='$date'"; + $e->databaseQuery($q); +// print "$q\n"; +} +?> diff --git a/scripts/update_eccs.sh b/scripts/update_eccs.sh new file mode 100755 index 0000000000000000000000000000000000000000..e4e98e92496b812faf5946dbcae989590e6d19d1 --- /dev/null +++ b/scripts/update_eccs.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# this is a temporary solution for ECCS status updates + +if [ ! -f /opt/eccs-deployment/debug/eccs_status ] ; then + exit +fi + +date >> /var/log/eccs_error.log +echo Starting >> /var/log/eccs_error.log +while ! grep -q 'end ECCS' /opt/eccs-deployment/debug/eccs_status ; do + sleep 10 +done +spath="$(readlink -n -f "$0")" +cd "$(dirname "$spath")" +/usr/bin/php ECCSinterface.php 2>&1 >>/var/log/eccs_error.log +date >> /var/log/eccs_error.log +echo Done >> /var/log/eccs_error.log \ No newline at end of file diff --git a/templates/js/entities.js b/templates/js/entities.js index 992512027360f621f8a578a8b12491b144fa7d40..2c477e73749e1a907c1c3875f7f53ee2edc2d030 100644 --- a/templates/js/entities.js +++ b/templates/js/entities.js @@ -57,8 +57,8 @@ $(function(){ win.focus(); }) - function show_eccs(e_id) { - var win = window.open(eccs_url+"?idp="+e_id,'_blank'); + function show_eccs(e_id, eccs_date) { + var win = window.open(eccs_url+"?idp="+e_id+"&date="+eccs_date,'_blank'); win.focus(); } @@ -79,15 +79,6 @@ $(function(){ show_coco(coco_id); }); - function show_clash(id) { - $.get("api.php",{action: 'show_entity_clashes', row_id: id}, function(data) { - var h = "<p>supplying federation: <strong>"+data.fed+"</strong><p>other federations: <strong>"+data.other_fed.join('</strong>, <strong>')+"<p>click the tooltip to close.</strong>"; - $("#clash_info").html(h); - $("#clash_info").css({'left':xx,'top':yy}); - $("#clash_info").show(); - }, 'json'); - } - $("#clash_info").on("click",function(event) { $(this).hide(); }); @@ -167,13 +158,26 @@ $("#clash_info").on("click",function(event) { $("#stat_sp").html(data.stats.sp); $("#stat_aa").html(data.stats.aa); $("#entities").html(data.html); -// $("body").css("cursor", "default"); - $("body").removeClass("busy"); + $("body").removeClass("busy"); $("#loading").hide(); - $("#list_entities").removeClass("busy"); - },'json'); - }); + $("#list_entities").removeClass("busy"); + $("div.eccs_status_box").tooltip({ + content: function() { + return '<div><strong>ECCS information</strong><p>'+$( this ).attr( "title" )+'</div>'; + } + }); + + $("div.clash_status_box").tooltip({ + content: function(result){ + $.get("api.php",{action: 'show_entity_clashes', row_id: $(this).attr('title')}, function(data) { + var h = "<strong>Clash information</strong><p>Supplying federation: <strong>"+data.fed+"</strong><p>other federations: <strong>"+data.other_fed.join('</strong>; <strong>')+"</strong>"; + result('<div>'+h+'</div>'); + }, 'json'); + } + }); + }); + }); $("#download_entities").click(function(event) { var ec = 0;