summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2016-03-03 11:49:35 +0100
committerJaime Perez Crespo <jaime.perez@uninett.no>2016-03-03 11:49:35 +0100
commitcbd20f6dfeed607b7b3e3165a42c0826ffc73915 (patch)
tree154a23a35a021872d193463c820dac6232162bc0 /lib/SimpleSAML
parentb96ddbfcd2a3cfa06cbc7fe48bcf6b7486a9930d (diff)
parentd4de56da714ffc46cfee0b066c723c21be527c79 (diff)
downloadsimplesamlphp-cbd20f6dfeed607b7b3e3165a42c0826ffc73915.zip
simplesamlphp-cbd20f6dfeed607b7b3e3165a42c0826ffc73915.tar.gz
simplesamlphp-cbd20f6dfeed607b7b3e3165a42c0826ffc73915.tar.bz2
Merge branch 'bug/issue337'
* bug/issue337: Rename Utils\HTTP::getSelfHostWithoutPort() to Utils\HTTP::getSelfHostWithNonStandardPort(), change the logic, and reimplement Utils\HTTP::getSelfHost() to depend on use the former. Complete the tests to include the case of port 443 while using HTTPS. Fixes issue 337
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Metadata/MetaDataStorageHandler.php4
-rw-r--r--lib/SimpleSAML/Metadata/MetaDataStorageSource.php4
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php27
3 files changed, 22 insertions, 13 deletions
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
index 3903e72..5c1c6e8 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
@@ -208,10 +208,6 @@ class SimpleSAML_Metadata_MetaDataStorageHandler
// then we look for the hostname
$currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
- if (strpos($currenthost, ":") !== false) {
- $currenthostdecomposed = explode(":", $currenthost);
- $currenthost = $currenthostdecomposed[0];
- }
foreach ($this->sources as $source) {
$index = $source->getEntityIdFromHostPath($currenthost, $set, $type);
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
index bc7e896..9d677cd 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php
@@ -199,10 +199,6 @@ abstract class SimpleSAML_Metadata_MetaDataStorageSource
// check for hostname
$currenthost = \SimpleSAML\Utils\HTTP::getSelfHost(); // sp.example.org
- if (strpos($currenthost, ":") !== false) {
- $currenthostdecomposed = explode(":", $currenthost);
- $currenthost = $currenthostdecomposed[0];
- }
foreach ($metadataSet as $index => $entry) {
if ($index === $entityId) {
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 5f791de..00946fc 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -336,7 +336,7 @@ class HTTP
/**
- * Helper function to retrieve a file or URL with proxy support, also
+ * Helper function to retrieve a file or URL with proxy support, also
* supporting proxy basic authorization..
*
* An exception will be thrown if we are unable to retrieve the data.
@@ -595,22 +595,39 @@ class HTTP
/**
* Retrieve our own host.
*
- * @return string The current host (with non-default ports included).
+ * E.g. www.example.com
+ *
+ * @return string The current host.
+ *
+ * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
+ */
+ public static function getSelfHost()
+ {
+ return array_shift(explode(':', self::getSelfHostWithNonStandardPort()));
+ }
+
+ /**
+ * Retrieve our own host, including the port in case the it is not standard for the protocol in use. That is port
+ * 80 for HTTP and port 443 for HTTPS.
+ *
+ * E.g. www.example.com:8080
+ *
+ * @return string The current host, followed by a colon and the port number, in case the port is not standard for
+ * the protocol.
*
* @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
* @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
*/
- public static function getSelfHost()
+ public static function getSelfHostWithNonStandardPort()
{
$url = self::getBaseURL();
$start = strpos($url, '://') + 3;
- $length = strcspn($url, '/:', $start);
+ $length = strcspn($url, '/', $start);
return substr($url, $start, $length);
}
-
/**
* Retrieve our own host together with the URL path. Please note this function will return the base URL for the
* current SP, as defined in the global configuration.