Commit 5df46309 authored by Lukas Haemmerle's avatar Lukas Haemmerle

Fixed conflict from branch 'rousse/SWITCHwayf-master+update-metadata'

parents f54284cd 742727d0
......@@ -7,7 +7,7 @@ if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed');
}
$toplevelDir = dirname(__DIR__);
$topLevelDir = dirname(__DIR__);
$distConfigFilePath = $topLevelDir . '/etc/config.dist.php');
$newConfigFilePath = $topLevelDir . '/etc/config.new.php');
$currentConfigFilePath = $topLevelDir . '/etc/config.php');
......
......@@ -2,17 +2,19 @@
$MAN=<<<PAGE
Name: SWITCHwayf
Author: Lukas Haemmerle, SWITCH
Description: This file is used to dynamically create the list of
Description: This script is used to dynamically create the list of
IdPs and SP to be displayed for the WAYF/DS service
based on the federation metadata.
Configuration parameters are specified in config.php.
The list of Identity Providers can also be updated
by running the script update-metadata.php
periodically as web server user, e.g. with a cron
It is intended to be run periodically, e.g. with a cron
entry like:
5 * * * * /usr/bin/php update-metadata.php > /dev/null
5 * * * * /usr/bin/php update-metadata.php \
--metadata-file /var/cache/shibboleth/metadata.switchaai.xml \
--metadata-idp-file /tmp/IDProvider.metadata.php \
--metadata-sp-file /tmp/SProvider.metadata.php \
> /dev/null
Usage:
Usage
-----
php update-metadata.php -help|-h
php update-metadata.php --metadata-file <file> \
--metadata-idp-file <file> --metadata-sp-file <file> \
......@@ -21,16 +23,8 @@ php update-metadata.php --metadata-url <url> \
--metadata-idp-file <file> --metadata-sp-file <file> \
[--verbose | -v] [--min-sp-count <count>] [--min-idp-count <count>]
Example usage:
php update-metadata.php \
--metadata-file /var/cache/shibboleth/metadata.switchaai.xml \
--metadata-idp-file /tmp/IDProvider.metadata.php \
--metadata-sp-file /tmp/SProvider.metadata.php
Argument Description
-------------------
Argument Description
--------------------
--metadata-url <url> SAML2 metadata URL
--metadata-file <file> SAML2 metadata file
--metadata-idp-file <file> File containing Service Providers
......@@ -39,12 +33,12 @@ Argument Description
--min-sp-count <count> Minimum expected number of SPs in metadata
--language <locale> Language locale, e.g. 'en', 'jp', ...
--verbose | -v Verbose mode
--help | -h Print this man page
--help | -h Print this man page
PAGE;
$toplevelDir = dirname(__DIR__);
$topLevelDir = dirname(__DIR__);
require_once($topLevelDir . '/lib/functions.php');
require_once($topLevelDir . '/lib/readMetadata.php');
......@@ -156,7 +150,7 @@ if (is_array($metadataIDProviders)){
}
if ($verbose) {
echo "Dumping parsed Identity Providers to file $metadataIDPFile\n";
echo "Dumping $IDPCount extracted Identity Providers to file $metadataIDPFile\n";
}
dumpFile($metadataTempIDPFile, $metadataIDProviders, 'metadataIDProviders');
......@@ -173,7 +167,7 @@ if (is_array($metadataSProviders)){
}
if ($verbose) {
echo "Dumping parsed Service Providers to file $metadataSPFile\n";
echo "Dumping $SPCount extracted Service Providers to file $metadataSPFile\n";
}
dumpFile($metadataTempSPFile, $metadataSProviders, 'metadataSProviders');
......
......@@ -46,8 +46,8 @@ function updateMetadata() {
// Now merge IDPs from metadata and static file
$IDProviders = mergeInfo($IDProviders, $metadataIDProviders, $SAML2MetaOverLocalConf, $includeLocalConfEntries);
// For now copy the array by reference
$SProviders = &$metadataSProviders;
// There is no static file for SPs, use metadata only
$SProviders = $metadataSProviders;
} elseif (file_exists($metadataIDPFile)) {
......@@ -70,8 +70,8 @@ function updateMetadata() {
// Now merge IDPs from metadata and static file
$IDProviders = mergeInfo($IDProviders, $metadataIDProviders, $SAML2MetaOverLocalConf, $includeLocalConfEntries);
// For now copy the array by reference
$SProviders = &$metadataSProviders;
// There is no static file for SPs, use metadata only
$SProviders = $metadataSProviders;
}
// Close the metadata lock file.
......
......@@ -21,13 +21,7 @@ function printHeader(){
global $federationURL, $organizationURL, $faqURL, $helpURL, $privacyURL;
global $customStrings;
// Check if custom header template exists
if(file_exists('custom-header.php')){
include('custom-header.php');
} else {
// Use default code
include('default-header.php');
}
include(get_template('header.php'));
}
......@@ -87,13 +81,7 @@ function printWAYF(){
$defaultSelected = ($selectedIDP == '-') ? 'selected="selected"' : '';
$rememberSelectionChecked = (isset($_COOKIE[$redirectStateCookieName])) ? 'checked="checked"' : '' ;
// Check if custom header template exists
if(file_exists('custom-body.php')){
include('custom-body.php');
} else {
// Use default code
include('default-body.php');
}
include(get_template('body.php'));
}
/******************************************************************************/
......@@ -106,13 +94,7 @@ function printSettings(){
$actionURL = $_SERVER['SCRIPT_NAME'].'?'.htmlentities($_SERVER['QUERY_STRING']);
$defaultSelected = ($selectedIDP == '-') ? 'selected="selected"' : '';
// Check if custom header template exists
if(file_exists('custom-settings.php')){
include('custom-settings.php');
} else {
// Use default code
include('default-settings.php');
}
include(get_template('settings.php'));
}
/******************************************************************************/
......@@ -271,28 +253,13 @@ function printNotice(){
}
}
// Check if footer template exists
if(file_exists('custom-notice.php')){
include('custom-notice.php');
} else {
// Use default code
include('default-notice.php');
}
include(get_template('notice.php'));
}
/******************************************************************************/
// Prints end of HTML page
function printFooter(){
global $customStrings;
// Check if footer template exists
if(file_exists('custom-footer.php')){
include('custom-footer.php');
} else {
// Use default code
include('default-footer.php');
}
include(get_template('footer.php'));
}
/******************************************************************************/
......@@ -305,13 +272,7 @@ function printError($message){
// Show Header
printHeader();
// Check if error template exists
if(file_exists('custom-error.php')){
include('custom-error.php');
} else {
// Use default code
include('default-error.php');
}
include(get_template('error.php'));
// Show footer
printFooter();
......@@ -433,12 +394,7 @@ function printEmbeddedConfigurationScript(){
header('Content-type: text/plain;charset="utf-8"');
if(file_exists('custom-embedded-wayf.php')){
include('custom-embedded-wayf.php');
} else {
// Use default code
include('default-embedded-wayf.php');
}
include(get_template('embedded-wayf.php'));
}
/******************************************************************************/
......@@ -465,3 +421,14 @@ function printCSS($file){
echo $cssContent;
}
function get_template($name) {
global $topLevelDir;
$custom_template = $topLevelDir . '/lib/custom-' . $name;
$default_template = $topLevelDir . '/lib/default-' . $name;
return (file_exists($custom_template)) ?
$custom_template : $default_template;
}
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