Commit 6f33d3c9 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1650995: Move get discovery list to it's own function



behatnotneeded

Change-Id: I353fe7390d6f8fd2bbebc9bec01188428edf786e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 8665b925
...@@ -529,6 +529,27 @@ class PluginAuthSaml extends PluginAuth { ...@@ -529,6 +529,27 @@ class PluginAuthSaml extends PluginAuth {
return array($entityid, $idps); return array($entityid, $idps);
} }
public static function get_disco_list($lang = null, $entityidps = array()) {
if (empty($lang)) {
$lang = current_language();
}
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php');
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php');
SimpleSAML_Configuration::init(get_config('docroot') . 'auth/saml/config');
$discoHandler = new PluginAuthSaml_IdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'saml');
$disco = $discoHandler->getTheIdPs();
if (count($disco['list']) > 0) {
$lang = explode('.', $lang);
$lang = strtolower(array_shift($lang));
foreach($disco['list'] as $idp) {
$idpname = (isset($idp['name'][$lang])) ? $idp['name'][$lang] : $idp['entityid'];
$entityidps[$idp['entityid']] = $idpname;
}
return $entityidps;
}
return false;
}
public static function get_instance_config_options($institution, $instance = 0) { public static function get_instance_config_options($institution, $instance = 0) {
if (!class_exists('SimpleSAML_XHTML_IdPDisco')) { if (!class_exists('SimpleSAML_XHTML_IdPDisco')) {
global $SESSION; global $SESSION;
...@@ -593,20 +614,10 @@ class PluginAuthSaml extends PluginAuth { ...@@ -593,20 +614,10 @@ class PluginAuthSaml extends PluginAuth {
$entityidps = array(); $entityidps = array();
$entityidp_hiddenlabel = true; $entityidp_hiddenlabel = true;
// Fetch the idp info via disco // Fetch the idp info via disco
require_once(get_config('docroot') . 'auth/saml/extlib/simplesamlphp/vendor/autoload.php'); $discolist = self::get_disco_list();
require_once(get_config('docroot') . 'auth/saml/extlib/_autoload.php'); if ($discolist) {
SimpleSAML_Configuration::init(get_config('docroot') . 'auth/saml/config'); $entityidps += $discolist;
$discoHandler = new PluginAuthSaml_IdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'saml');
$disco = $discoHandler->getTheIdPs();
if (count($disco['list']) > 0) {
$lang = current_language();
$lang = explode('.', $lang);
$lang = strtolower(array_shift($lang));
$entityidp_hiddenlabel = false; $entityidp_hiddenlabel = false;
foreach($disco['list'] as $idp) {
$idpname = (isset($idp['name'][$lang])) ? $idp['name'][$lang] : $idp['entityid'];
$entityidps[$idp['entityid']] = $idpname;
}
} }
asort($entityidps); asort($entityidps);
// add the 'New' option to the top of the list // add the 'New' option to the top of the list
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment