Skip to content
Snippets Groups Projects
Commit d4f28ae0 authored by Tomasz Wolniewicz's avatar Tomasz Wolniewicz
Browse files

Changes mainly to improve integration with ECCS plus some cosmetics on the...

Changes mainly to improve integration with ECCS plus some cosmetics on the entities database interface
parent c6e8e645
Branches
Tags
1 merge request!34Synchronising with TW fork
# 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;
...@@ -80,6 +80,7 @@ DROP TABLE IF EXISTS `eccs_stat`; ...@@ -80,6 +80,7 @@ DROP TABLE IF EXISTS `eccs_stat`;
CREATE TABLE `eccs_stat` ( CREATE TABLE `eccs_stat` (
`entityid` char(255) COLLATE utf8_unicode_ci DEFAULT NULL, `entityid` char(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` int(1) DEFAULT NULL, `status` int(1) DEFAULT NULL,
`update_date` DATE DEFAULT NULL,,
UNIQUE KEY `entityid` (`entityid`) UNIQUE KEY `entityid` (`entityid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
...@@ -235,6 +236,7 @@ CREATE TABLE `entity_details` ( ...@@ -235,6 +236,7 @@ CREATE TABLE `entity_details` (
`roles` tinyint(4) DEFAULT NULL, `roles` tinyint(4) DEFAULT NULL,
`saml2_support` tinyint(4) DEFAULT '0', `saml2_support` tinyint(4) DEFAULT '0',
`eccs_status` int(1) DEFAULT '0', `eccs_status` int(1) DEFAULT '0',
`eccs_status_date` DATE DEFAULT NULL,
`validator_status` bigint(20) DEFAULT NULL, `validator_status` bigint(20) DEFAULT NULL,
`clash` int(1) DEFAULT '0', `clash` int(1) DEFAULT '0',
`coco_status` int(1) DEFAULT NULL, `coco_status` int(1) DEFAULT NULL,
......
...@@ -10,7 +10,7 @@ INSERT INTO entity_details (entity_id,saml2_support) select entity_id, max(saml2 ...@@ -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); 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; 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); 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);
......
...@@ -814,6 +814,7 @@ class eduGAIN_entity extends eduGAIN { ...@@ -814,6 +814,7 @@ class eduGAIN_entity extends eduGAIN {
case 'IDPSSODescriptor': case 'IDPSSODescriptor':
$entity['role'][$roledesc]['type'] = 'IdP'; $entity['role'][$roledesc]['type'] = 'IdP';
$entity['eccs_status'] = $R['eccs_status']; $entity['eccs_status'] = $R['eccs_status'];
$entity['eccs_status_date'] = $R['eccs_status_date'];
break; break;
case 'AttributeAuthorityDescriptor': case 'AttributeAuthorityDescriptor':
$entity['role'][$roledesc]['type'] = 'AA'; $entity['role'][$roledesc]['type'] = 'AA';
...@@ -945,7 +946,7 @@ class eduGAIN_entity extends eduGAIN { ...@@ -945,7 +946,7 @@ class eduGAIN_entity extends eduGAIN {
if ($V['type'] == 'IdP' && $entity['eccs_status'] != 0) { if ($V['type'] == 'IdP' && $entity['eccs_status'] != 0) {
$td_s = "background:".Constants::ECCS_Colours[$entity['eccs_status']][1]."; text-align:center"; $td_s = "background:".Constants::ECCS_Colours[$entity['eccs_status']][1]."; text-align:center";
$a_s = "color:".Constants::ECCS_Colours[$entity['eccs_status']][0]; $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 { } else {
$eccs = ''; $eccs = '';
} }
...@@ -958,7 +959,7 @@ class eduGAIN_entity extends eduGAIN { ...@@ -958,7 +959,7 @@ class eduGAIN_entity extends eduGAIN {
$td_s = "background:red; text-align:center"; $td_s = "background:red; text-align:center";
$a_s = "color:white"; $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 { } else {
$clash = ''; $clash = '';
} }
...@@ -1123,10 +1124,10 @@ class eduGAIN_entity extends eduGAIN { ...@@ -1123,10 +1124,10 @@ class eduGAIN_entity extends eduGAIN {
} }
switch ($sirtfi) { switch ($sirtfi) {
case 1 : case 1 :
$search_filter .= " AND entity_details.sirtfi > 0"; $search_filter .= " AND entity_details.sirtfi > 0"; // SIRTFI asserted
break; break;
case 2 : case 2 :
$search_filter .= " AND entity_details.sirtfi = 2"; $search_filter .= " AND entity_details.sirtfi = 2"; // SIRTFI errors
break; break;
default : default :
break; break;
...@@ -1164,7 +1165,7 @@ class eduGAIN_entity extends eduGAIN { ...@@ -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'"; $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, "database query: $q\n");
Utils::debug(4, "join: $cat_join\n"); Utils::debug(4, "join: $cat_join\n");
Utils::debug(4, "filter:$search_filter\n"); Utils::debug(4, "filter:$search_filter\n");
......
<?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";
}
?>
#!/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
...@@ -57,8 +57,8 @@ $(function(){ ...@@ -57,8 +57,8 @@ $(function(){
win.focus(); win.focus();
}) })
function show_eccs(e_id) { function show_eccs(e_id, eccs_date) {
var win = window.open(eccs_url+"?idp="+e_id,'_blank'); var win = window.open(eccs_url+"?idp="+e_id+"&date="+eccs_date,'_blank');
win.focus(); win.focus();
} }
...@@ -79,15 +79,6 @@ $(function(){ ...@@ -79,15 +79,6 @@ $(function(){
show_coco(coco_id); 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) { $("#clash_info").on("click",function(event) {
$(this).hide(); $(this).hide();
}); });
...@@ -167,13 +158,26 @@ $("#clash_info").on("click",function(event) { ...@@ -167,13 +158,26 @@ $("#clash_info").on("click",function(event) {
$("#stat_sp").html(data.stats.sp); $("#stat_sp").html(data.stats.sp);
$("#stat_aa").html(data.stats.aa); $("#stat_aa").html(data.stats.aa);
$("#entities").html(data.html); $("#entities").html(data.html);
// $("body").css("cursor", "default"); $("body").removeClass("busy");
$("body").removeClass("busy");
$("#loading").hide(); $("#loading").hide();
$("#list_entities").removeClass("busy"); $("#list_entities").removeClass("busy");
},'json');
});
$("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) { $("#download_entities").click(function(event) {
var ec = 0; var ec = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment