summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/SimpleSAML/Error/Error.php2
-rw-r--r--lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php2
-rw-r--r--lib/SimpleSAML/Module.php2
-rw-r--r--lib/SimpleSAML/Utilities.php40
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php41
-rw-r--r--modules/adfs/lib/IdP/ADFS.php2
-rw-r--r--modules/core/www/frontpage_config.php4
-rw-r--r--modules/core/www/frontpage_federation.php2
-rw-r--r--www/admin/hostnames.php2
-rw-r--r--www/saml2/idp/metadata.php4
10 files changed, 53 insertions, 48 deletions
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index a422e62..2c035bc 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -265,7 +265,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
if($config->getBoolean('errorreporting', TRUE) &&
$config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
/* Enable error reporting. */
- $baseurl = SimpleSAML_Utilities::getBaseURL();
+ $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
$data['errorReportAddress'] = $baseurl . 'errorreport.php';
}
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
index 22688c2..b028bb4 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php
@@ -116,7 +116,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerFlatFile extends SimpleSAML_Meta
private function generateDynamicHostedEntityID($set) {
/* Get the configuration. */
- $baseurl = SimpleSAML_Utilities::getBaseURL();
+ $baseurl = \SimpleSAML\Utils\HTTP::getBaseURL();
if ($set === 'saml20-idp-hosted') {
return $baseurl . 'saml2/idp/metadata.php';
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index 829fa7b..45b1ae6 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -155,7 +155,7 @@ class SimpleSAML_Module {
assert('is_string($resource)');
assert('$resource[0] !== "/"');
- $url = SimpleSAML_Utilities::getBaseURL() . 'module.php/' . $resource;
+ $url = \SimpleSAML\Utils\HTTP::getBaseURL() . 'module.php/' . $resource;
if (!empty($parameters)) {
$url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters);
}
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 81d8a28..b592539 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -208,46 +208,10 @@ class SimpleSAML_Utilities {
/**
- * Retrieve and return the absolute base URL for the simpleSAMLphp installation.
- *
- * For example: https://idp.example.org/simplesaml/
- *
- * The URL will always end with a '/'.
- *
- * @return string The absolute base URL for the simpleSAMLphp installation.
+ * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getBaseURL() instead.
*/
public static function getBaseURL() {
-
- $globalConfig = SimpleSAML_Configuration::getInstance();
- $baseURL = $globalConfig->getString('baseurlpath', 'simplesaml/');
-
- if (preg_match('#^https?://.*/$#D', $baseURL, $matches)) {
- /* full URL in baseurlpath, override local server values */
- return $baseURL;
- } elseif (
- (preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) ||
- (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) ||
- ($baseURL === '')) {
- /* get server values */
-
- if (self::getServerHTTPS()) {
- $protocol = 'https://';
- } else {
- $protocol = 'http://';
- }
-
- $hostname = self::getServerHost();
- $port = self::getServerPort();
- $path = '/' . $globalConfig->getBaseURL();
-
- return $protocol.$hostname.$port.$path;
- } else {
- throw new SimpleSAML_Error_Exception('Invalid value of \'baseurl\' in '.
- 'config.php. Valid format is in the form: '.
- '[(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]. '.
- 'It must end with a \'/\'.');
- }
-
+ return \SimpleSAML\Utils\HTTP::getBaseURL();
}
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 5c50427..96577ff 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -208,6 +208,47 @@ class HTTP
/**
+ * Retrieve the base URL of the SimpleSAMLphp installation. The URL will always end with a '/'. For example:
+ * https://idp.example.org/simplesaml/
+ *
+ * @return string The absolute base URL for the simpleSAMLphp installation.
+ * @throws \SimpleSAML_Error_Exception If 'baseurlpath' has an invalid format.
+ *
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ */
+ public static function getBaseURL()
+ {
+ $globalConfig = \SimpleSAML_Configuration::getInstance();
+ $baseURL = $globalConfig->getString('baseurlpath', 'simplesaml/');
+
+ if (preg_match('#^https?://.*/$#D', $baseURL, $matches)) {
+ // full URL in baseurlpath, override local server values
+ return $baseURL;
+ } elseif (
+ (preg_match('#^/?([^/]?.*/)$#D', $baseURL, $matches)) ||
+ (preg_match('#^\*(.*)/$#D', $baseURL, $matches)) ||
+ ($baseURL === '')
+ ) {
+ // get server values
+ $protocol = 'http';
+ $protocol .= (self::getServerHTTPS()) ? 's' : '';
+ $protocol .= '://';
+
+ $hostname = self::getServerHost();
+ $port = self::getServerPort();
+ $path = '/'.$globalConfig->getBaseURL();
+
+ return $protocol.$hostname.$port.$path;
+ } else {
+ throw new \SimpleSAML_Error_Exception('Invalid value for \'baseurlpath\' in '.
+ 'config.php. Valid format is in the form: '.
+ '[(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]. '.
+ 'It must end with a \'/\'.');
+ }
+ }
+
+
+ /**
* Parse a query string into an array.
*
* This function parses a query string into an array, similar to the way the builtin 'parse_str' works, except it
diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php
index a96e005..610f84b 100644
--- a/modules/adfs/lib/IdP/ADFS.php
+++ b/modules/adfs/lib/IdP/ADFS.php
@@ -168,7 +168,7 @@ class sspmod_adfs_IdP_ADFS {
// NB:: we don't know from which SP the logout request came from
$metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$idpMetadata = $idp->getConfig();
- SimpleSAML_Utilities::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', SimpleSAML_Utilities::getBaseURL()));
+ SimpleSAML_Utilities::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL()));
}
public static function receiveLogoutMessage(SimpleSAML_IdP $idp) {
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index 7e4cc4f..e97eb4b 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -44,12 +44,12 @@ $links_federation = array();
$links_config[] = array(
- 'href' => SimpleSAML_Utilities::getBaseURL() . 'admin/hostnames.php',
+ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/hostnames.php',
'text' => '{core:frontpage:link_diagnostics}'
);
$links_config[] = array(
- 'href' => SimpleSAML_Utilities::getBaseURL() . 'admin/phpinfo.php',
+ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/phpinfo.php',
'text' => '{core:frontpage:link_phpinfo}'
);
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index 5e32a10..aab31a5 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -37,7 +37,7 @@ if($config->getBoolean('idpdisco.enableremember', FALSE)) {
$links_federation[] = array(
- 'href' => SimpleSAML_Utilities::getBaseURL() . 'admin/metadata-converter.php',
+ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/metadata-converter.php',
'text' => '{core:frontpage:link_xmlconvert}',
);
diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php
index 93b6180..0a520a9 100644
--- a/www/admin/hostnames.php
+++ b/www/admin/hostnames.php
@@ -16,7 +16,7 @@ $attributes['HTTPS'] = array($_SERVER['HTTPS']);
$attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']);
$attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']);
-$attributes['Utilities_getBaseURL()'] = array(SimpleSAML_Utilities::getBaseURL());
+$attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL());
$attributes['Utilities_getSelfHost()'] = array(SimpleSAML_Utilities::getSelfHost());
$attributes['Utilities_selfURLhost()'] = array(SimpleSAML_Utilities::selfURLhost());
$attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery());
diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index 67d56ca..6f7377c 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -105,7 +105,7 @@ try {
/* Artifact sending enabled. */
$metaArray['ArtifactResolutionService'][] = array(
'index' => 0,
- 'Location' => SimpleSAML_Utilities::getBaseURL() . 'saml2/idp/ArtifactResolutionService.php',
+ 'Location' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'saml2/idp/ArtifactResolutionService.php',
'Binding' => SAML2_Const::BINDING_SOAP,
);
}
@@ -115,7 +115,7 @@ try {
array_unshift($metaArray['SingleSignOnService'], array(
'hoksso:ProtocolBinding' => SAML2_Const::BINDING_HTTP_REDIRECT,
'Binding' => SAML2_Const::BINDING_HOK_SSO,
- 'Location' => SimpleSAML_Utilities::getBaseURL() . 'saml2/idp/SSOService.php'));
+ 'Location' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'saml2/idp/SSOService.php'));
}
$metaArray['NameIDFormat'] = $idpmeta->getString('NameIDFormat', 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient');