Commit 3e2778dd authored by haemmer's avatar haemmer

Added features for #2983

Minor code restructing for #3139
parent 331cd211
......@@ -63,8 +63,19 @@
//$showPermanentSetting = false;
// Whether or not to use the search-as-you-type feature of the drop down list
// Enabling this will use JavaScript to convert the select element containing
// all Identity Providers to a searchable search-as-you-type list that also
// displays logos if available
//$useImprovedDropDownList = true;
// If true the improved drop-down-list will not display logos that
// have to be loaded from remote URLs. That way the web browser
// does not have to make requests to third party hosts.
// Logos that are embedded using data URIs
// (src="data:image/png;base64...") will however still be displayed
//$disableRemoteLogos = false;
// Number of previously used Identity Providers to show at top of drop-down list
// Default is 3, set to 0 to disable
//$showNumOfPreviouslyUsedIdPs = 3;
......
......@@ -147,6 +147,16 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// [Optional, default: false]
// var wayf_use_improved_drop_down_list = false;
// If true the improved drop-down-list will not display IdP logos that
// have to be loaded from remote URLs. That way the web browser
// does not have to make requests to third party hosts.
// Logos that are embedded using data URIs
// (src="data:image/png;base64...") will however still be displayed
// Don't confuse this with wayf_hide_logo, which shows or hides
// the logo of this WAYF instance
// [Optional, default: false]
// wayf_disable_remote_idp_logos = false;
// Force the user's Home Organisation selection to be remembered for the
// current browser session. If wayf_show_remember_checkbox is true
// the checkbox will be shown but will be read only.
......
......@@ -71,7 +71,8 @@
$("#userIdPSelection:enabled").improveDropDown({
iconPath:'<?php echo $imageURL ?>/drop_icon.png',
noMatchesText: '<?php echo getLocalString('no_idp_found', 'js') ?>',
noItemsText: '<?php echo getLocalString('no_idp_available', 'js') ?>'
noItemsText: '<?php echo getLocalString('no_idp_available', 'js') ?>',
disableRemoteLogos: <?php echo ($disableRemoteLogos) ? 'true' : 'false' ?>
});
}
}
......
......@@ -19,6 +19,7 @@ function initConfigOptions(){
global $cookieValidity;
global $showPermanentSetting;
global $useImprovedDropDownList;
global $disableRemoteLogos;
global $useSAML2Metadata;
global $SAML2MetaOverLocalConf;
global $includeLocalConfEntries;
......@@ -52,8 +53,10 @@ function initConfigOptions(){
global $metadataLockFile;
global $WAYFLogFile;
global $kerberosRedirectURL;
global $instanceIdentifier;
global $developmentMode;
// Set independet default configuration options
$defaults = array();
$defaults['defaultLanguage'] = 'en';
......@@ -63,6 +66,7 @@ function initConfigOptions(){
$defaults['cookieValidity'] = 100;
$defaults['showPermanentSetting'] = false;
$defaults['useImprovedDropDownList'] = true;
$defaults['disableRemoteLogos'] = false;
$defaults['useSAML2Metadata'] = false;
$defaults['SAML2MetaOverLocalConf'] = false;
$defaults['includeLocalConfEntries'] = true;
......@@ -93,6 +97,7 @@ function initConfigOptions(){
$defaults['metadataLockFile'] = (substr($_SERVER['PATH'],0,1) == '/') ? '/tmp/wayf_metadata.lock' : 'C:\windows\TEMP';
$defaults['WAYFLogFile'] = '/var/log/apache2/wayf.log';
$defaults['kerberosRedirectURL'] = dirname($_SERVER['SCRIPT_NAME']).'kerberosRedirect.php';
$defaults['instanceIdentifier'] = 'SWITCHwayf';
$defaults['developmentMode'] = false;
// Initialize independent defaults
......@@ -760,12 +765,7 @@ function logAccessEntry($protocol, $type, $sp, $idp, $return){
function initLogger(){
global $instanceIdentifier;
$logIdentifier = 'SWITCHwayf';
if (isset($instanceIdentifier) && !empty($instanceIdentifier)){
$logIdentifier = $instanceIdentifier;
}
openlog($logIdentifier, LOG_NDELAY, LOG_USER);
openlog($instanceIdentifier, LOG_NDELAY, LOG_USER);
}
/******************************************************************************/
......
......@@ -17,6 +17,7 @@ var wayf_sp_handlerURL;
// Other settings
var wayf_use_discovery_service;
var wayf_use_improved_drop_down_list;
var wayf_disable_remote_idp_logos;
var wayf_use_small_logo;
var wayf_width;
var wayf_height;
......@@ -596,7 +597,8 @@ function loadImprovedDropDown(){
$("#user_idp:enabled").improveDropDown({
iconPath:'<?php echo $imageURL ?>/drop_icon.png',
noMatchesText: '<?php echo $noIdPFoundText ?>',
noItemsText: '<?php echo $noIdPAvailableText ?>'
noItemsText: '<?php echo $noIdPAvailableText ?>',
disableRemoteLogos: wayf_disable_remote_idp_logos
});
});
......@@ -625,6 +627,13 @@ function loadImprovedDropDown(){
wayf_use_improved_drop_down_list = false;
}
if(
typeof(wayf_disable_remote_idp_logos) == "undefined"
|| typeof(wayf_disable_remote_idp_logos) != "boolean"
){
wayf_disable_remote_idp_logos = false;
}
// Overwrite entityID with GET argument if present
var entityIDGETParam = getGETArgument("entityID");
if (entityIDGETParam != ""){
......
......@@ -60,11 +60,13 @@ var suspendTextBoxExitHandler = false;
var iconPath='./img/dropIcon.png';
var noMatchesText='No Matches';
var noItemsText='No Items Available';
var disableRemoteLogos=false;
if (arguments.length==1) {
if ('iconPath' in value) {iconPath = value.iconPath.toString();}
if ('noMatchesText' in value) {noMatchesText = value.noMatchesText.toString();}
if ('noItemsText' in value) {noItemsText = value.noItemsText.toString();}
if ('disableRemoteLogos' in value) {disableRemoteLogos = value.disableRemoteLogos;}
}
this.each(function () {
......@@ -83,6 +85,11 @@ var suspendTextBoxExitHandler = false;
var newListControl = getListElement(thisElement);
wrapperControl.append(newListControl);
// Remove logos from remote URL if this features is activated
if (disableRemoteLogos){
removeRemoteLogos(thisElement);
}
populateList(thisElement, newListControl,noMatchesText,noItemsText);
if (document.activeElement == thisElement[0]) {
......@@ -131,6 +138,30 @@ function getWrapperElement(sourceElement) {
return newWrapperElement;
}
function removeRemoteLogos(existingSelectControl){
var sourceListItems = existingSelectControl.find('OPTION');
if (sourceListItems.length == 0) {
return;
}
sourceListItems.each(
function () {
var optionItem = $(this);
// Skip items without logos
if (!optionItem.attr('logo')){
return;
}
// Remove logos that are not embedded as data URIs
if (optionItem.attr('logo').toLowerCase().indexOf('data:image') !== 0){
optionItem.removeAttr('logo');
}
});
}
function addLogoToTextElement(newTextElement, url){
if (!displayLogos){
......
......@@ -16,7 +16,8 @@ if(!isset($_SERVER['REMOTE_ADDR']) || basename($_SERVER['SCRIPT_NAME']) == 'temp
function printHeader(){
global $langStrings, $language, $imageURL, $javascriptURL, $cssURL, $logoURL, $useImprovedDropDownList, $organizationLogoURL;
global $langStrings, $language, $imageURL, $javascriptURL, $cssURL, $logoURL;
global $useImprovedDropDownList, $disableRemoteLogos, $organizationLogoURL;
global $federationURL, $organizationURL, $faqURL, $helpURL, $privacyURL;
// Check if custom header template exists
......
Markdown is supported
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