From d6b5b9998ae979e129752f50ddf689997745d75e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 25 Jun 2020 12:07:09 +0200 Subject: Allow overriding default config --- extras/import-idp.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extras/import-idp.php b/extras/import-idp.php index b18b923..4518bbf 100644 --- a/extras/import-idp.php +++ b/extras/import-idp.php @@ -24,6 +24,12 @@ while (($line = fgets($handle)) !== false) { } fclose($handle); +// Default/Fallback +$requiredAttribute = 'http://aai.dfn.de/category/bwidm-member'; +$url = 'https://www.aai.dfn.de/fileadmin/metadata/dfn-aai-metadata.xml'; +$f = __DIR__ . '/shib.conf.php'; +if (is_readable($f)) require_once $f; + $ch = curl_init(); if ($ch === false) die("Could not init curl\n"); @@ -33,7 +39,6 @@ $db = new mysqli($settings['host'], $settings['user'], $settings['password'], $s if ($db->connect_errno) die("Could not connect to db: " . $db->connect_error . "\n"); $db->set_charset("utf8"); -$url = 'https://www.aai.dfn.de/fileadmin/metadata/dfn-aai-metadata.xml'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); @@ -118,7 +123,7 @@ foreach ($out[0] as $data) { pdebug(" *** Entry without DisplayName..."); continue; } - if (!in_array('http://aai.dfn.de/category/bwidm-member', getAttributes($xml, 'Extensions/EntityAttributes/Attribute/AttributeValue'))) { + if ($requiredAttribute !== false && !in_array($requiredAttribute, getAttributes($xml, 'Extensions/EntityAttributes/Attribute/AttributeValue'))) { pdebug("Not bwIDM member..."); continue; } -- cgit v1.2.3-55-g7522