Commit 2ae94956 authored by Guillaume Rousse's avatar Guillaume Rousse

project files reorganisation

- config files are now in etc subdirectory
- web files are now in www subdirectory
- library files are now in lib subdirectory
- script files are now in bin subdirectory
parent 8b0040aa
...@@ -53,7 +53,7 @@ Installation ...@@ -53,7 +53,7 @@ Installation
This file contains the list of Identity Providers that that can be This file contains the list of Identity Providers that that can be
configured by hand configured by hand
3. Enure that permissions for the files: 3. Ensure that permissions for the files:
- SProvider.metadata.php - SProvider.metadata.php
- IDProvider.metadata.php - IDProvider.metadata.php
- metadata.lock - metadata.lock
...@@ -64,12 +64,12 @@ Installation ...@@ -64,12 +64,12 @@ Installation
4. Adapt the SWITCHwayf configuration in config.php. There are comments in that 4. Adapt the SWITCHwayf configuration in config.php. There are comments in that
file that should help you make suitable choices for your use case. file that should help you make suitable choices for your use case.
5. If Apache 2 is used, add the following statement to the Apache configugration: 5. If Apache 2 is used, add the following statement to the Apache configuration:
-- --
Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf/www
<Directory /#YOUR-PATH-TO#/SWITCHwayf> <Directory /#YOUR-PATH-TO#/SWITCHwayf/www>
Options Indexes MultiViews Options Indexes MultiViews
AllowOverride None AllowOverride None
Order allow,deny Order allow,deny
...@@ -83,6 +83,7 @@ Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf ...@@ -83,6 +83,7 @@ Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf
</Directory> </Directory>
-- --
Beware, only the www subdirectory should be exposed, not the top-level directory.
Alternatively, one also could rename the file 'WAYF' to 'WAYF.php'. Alternatively, one also could rename the file 'WAYF' to 'WAYF.php'.
......
...@@ -7,19 +7,25 @@ if (isset($_SERVER['REMOTE_ADDR'])){ ...@@ -7,19 +7,25 @@ if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed'); exit('No direct script access allowed');
} }
if (!file_exists('config.dist.php')) { $toplevelDir = dirname(__DIR__);
die('The default configuration file config.dist.php does not exist in this directory!'); $distConfigFilePath = $topLevelDir . '/etc/config.dist.php');
$newConfigFilePath = $topLevelDir . '/etc/config.new.php');
$currentConfigFilePath = $topLevelDir . '/etc/config.php');
if (!file_exists($distConfigFilePath)) {
die("The default configuration file 'config.dist.php' does not exist in configuration directory!");
} }
if (!file_exists('config.php')) { if (!file_exists($currentConfigFilePath)) {
die('The configuration file config.php does not exist in this directory!'); die("The configuration file 'config.php' does not exist in configuration directory!");
} }
require_once('config.php'); require_once($currentConfigFilePath);
echo "Parsing current configuration and default configuration...\n"; echo "Parsing current configuration and default configuration...\n";
$fp = fopen('config.new.php', 'w') or die("Cannot open file 'config.new.php' for writing!") ; $fp = fopen($newConfigFilePath, 'w')
$distConfigFile = file('config.dist.php'); or die("Cannot open file 'config.new.php' for writing!") ;
$currentConfigFile = file('config.php'); $distConfigFile = file($distConfigFilePath);
$currentConfigFile = file($currentConfigFilePath);
$configSettings = Array(); $configSettings = Array();
foreach ($currentConfigFile as $line){ foreach ($currentConfigFile as $line){
......
...@@ -44,8 +44,10 @@ Argument Description ...@@ -44,8 +44,10 @@ Argument Description
PAGE; PAGE;
require_once('functions.php'); $toplevelDir = dirname(__DIR__);
require_once('readMetadata.php');
require_once($topLevelDir . '/lib/functions.php');
require_once($topLevelDir . '/lib/readMetadata.php');
// Script options // Script options
$longopts = array( $longopts = array(
......
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
// 4. Files and path Settings // 4. Files and path Settings
//*************************** //***************************
// all relatives paths are resolved relatively to configuration directory
// Set both config files to the same value if you don't want to use the // Set both config files to the same value if you don't want to use the
// the WAYF to read a (potential) automatically generated file that undergoes // the WAYF to read a (potential) automatically generated file that undergoes
......
...@@ -55,6 +55,7 @@ function initConfigOptions(){ ...@@ -55,6 +55,7 @@ function initConfigOptions(){
global $kerberosRedirectURL; global $kerberosRedirectURL;
global $instanceIdentifier; global $instanceIdentifier;
global $developmentMode; global $developmentMode;
global $topLevelDir;
// Set independet default configuration options // Set independet default configuration options
...@@ -124,6 +125,17 @@ function initConfigOptions(){ ...@@ -124,6 +125,17 @@ function initConfigOptions(){
$$key = $value; $$key = $value;
} }
} }
// Turn relatives paths into absolute ones
$files = array(
'IDPConfigFile', 'backupIDPConfigFile', 'metadataFile',
'metadataIDPFile', 'metadataSPFile', 'metadataLockFile'
);
foreach($files as $file) {
if (substr($$file, 0, 1) != '/') {
$$file = $topLevelDir . '/etc/' . $$file;
}
}
} }
/******************************************************************************/ /******************************************************************************/
......
...@@ -13,21 +13,23 @@ Web site: https://www.switch.ch/aai/support/tools/wayf/ ...@@ -13,21 +13,23 @@ Web site: https://www.switch.ch/aai/support/tools/wayf/
// Load general configuration and template file // Load general configuration and template file
/*------------------------------------------------*/ /*------------------------------------------------*/
$topLevelDir = dirname(__DIR__);
if (isset($_SERVER{'SWITCHWAYF_CONFIG'})){ if (isset($_SERVER{'SWITCHWAYF_CONFIG'})){
require_once($_SERVER{'SWITCHWAYF_CONFIG'}); require_once($_SERVER{'SWITCHWAYF_CONFIG'});
} else { } else {
require_once('config.php'); require_once($topLevelDir . '/etc/config.php');
} }
require_once('languages.php'); require_once($topLevelDir . '/lib/languages.php');
require_once('functions.php'); require_once($topLevelDir . '/lib/functions.php');
require_once('templates.php'); require_once($topLevelDir . '/lib/templates.php');
// Set default config options // Set default config options
initConfigOptions(); initConfigOptions();
// Read custom locales // Read custom locales
if (file_exists('custom-languages.php')){ if (file_exists($topLevelDir . '/lib/custom-languages.php')){
require_once('custom-languages.php'); require_once($topLevelDir . '/lib/custom-languages.php');
} }
/*------------------------------------------------*/ /*------------------------------------------------*/
...@@ -62,7 +64,7 @@ if ($IDPConfigFile == $backupIDPConfigFile){ ...@@ -62,7 +64,7 @@ if ($IDPConfigFile == $backupIDPConfigFile){
// Read metadata file if configuration option is set // Read metadata file if configuration option is set
if($useSAML2Metadata && function_exists('xml_parser_create')){ if($useSAML2Metadata && function_exists('xml_parser_create')){
require('readMetadata.php'); require($topLevelDir . '/lib/readMetadata.php');
updateMetadata(); updateMetadata();
} }
......
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