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

Adding support for using a idplist API to retreive a list of idps with...

Adding support for using a idplist API to retreive a list of idps with successfull login at least once. used for weighting in discojuice

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2799 44740490-163a-0410-bde0-09ae8108e29a
parent 73ec0fe8
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,9 @@
*/
class sspmod_discojuice_Feed {
protected $config;
protected $config, $djconfig;
protected $exlude, $override, $insert;
protected $excludes, $override, $insert, $idplist;
protected $metadata;
protected $feed;
......@@ -22,6 +22,10 @@ class sspmod_discojuice_Feed {
$metadatah = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$this->metadata = $metadatah->getList('saml20-idp-remote');
$this->idplist = $this->getIdPList();
SimpleSAML_Logger::info('IdP List contained : ' . count($this->idplist) . ' entries.');
$this->excludes = array_flip($this->djconfig->getValue('exclude'));
$this->insert = $this->djconfig->getValue('insert');
$this->overrides = $this->djconfig->getValue('overrides');
......@@ -104,6 +108,21 @@ class sspmod_discojuice_Feed {
return (array_key_exists($e, $this->excludes));
}
protected function getIdPList() {
$api = $this->djconfig->getValue('idplistapi', NULL);
if (empty($api)) return array();
$result = array();
$apiresult = json_decode(file_get_contents($api), TRUE);
if ($apiresult['status'] === 'ok') {
foreach($apiresult['data'] AS $idp) {
$result[$idp] = 1;
}
}
return $result;
}
private function process() {
$this->feed = array();
......@@ -128,8 +147,11 @@ class sspmod_discojuice_Feed {
$this->getCountry($data, $m);
$this->getTitle($data, $m);
$this->getOverrides($data, $m);
$this->getGeo($data, $m);
if (!empty($this->idplist)) {
$this->islisted($data, $m);
}
return $data;
......@@ -141,6 +163,19 @@ class sspmod_discojuice_Feed {
}
protected function islisted(&$data, $m) {
$weight = 0;
if (array_key_exists('weight', $data)) $weight = $data['weight'];
if (!array_key_exists($m['entityid'], $this->idplist)) {
#echo 'Match for ' . $m['entityid'];
$weight += 2;
}
$data['weight'] = $weight;
# echo '<pre>';
# print_r($this->idplist); exit;
}
protected function getGeo(&$data, $m) {
......@@ -157,7 +192,11 @@ class sspmod_discojuice_Feed {
try {
$host = parse_url($endpoint['Location'], PHP_URL_HOST); if (empty($host)) return;
$ip = gethostbyname($host); if (empty($ip)) return;
$ip = gethostbyname($host);
if (empty($ip)) return;
if ($ip === $host) return;
$capi = new sspmod_discojuice_Country($ip);
if (empty($data['geo'])) {
......
......@@ -15,7 +15,7 @@ header('Content-Type: text/plain; charset=utf-8');
foreach($data AS $key => $e) {
if ($e['country'] == 'NO') {
if ($e['country'] == 'SE') {
print_r($e);
}
......
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