summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2016-06-08 12:04:18 +0200
committerJaime Perez Crespo <jaime.perez@uninett.no>2016-06-08 12:04:18 +0200
commitae40335bc7ef89c7012154d97a698019b3123bf7 (patch)
treef5b3bc38b5ad05608e1693cfd96ca7a737aa8634 /lib/SimpleSAML
parent677c3b0b6d03dad3eb922ef8bab88ba377ea3805 (diff)
downloadsimplesamlphp-ae40335bc7ef89c7012154d97a698019b3123bf7.zip
simplesamlphp-ae40335bc7ef89c7012154d97a698019b3123bf7.tar.gz
simplesamlphp-ae40335bc7ef89c7012154d97a698019b3123bf7.tar.bz2
Add a new SimpleSAML_Configuration::getBasePath() method as described in #364, deprecate getBaseURL() and make sure it generates a warning (and only one) when used.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/Configuration.php38
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php
index b477c8a..461f483 100644
--- a/lib/SimpleSAML/Configuration.php
+++ b/lib/SimpleSAML/Configuration.php
@@ -72,6 +72,14 @@ class SimpleSAML_Configuration
/**
+ * Temporary property that tells if the deprecated getBaseURL() method has been called or not.
+ *
+ * @var bool
+ */
+ private $deprecated_base_url_used = false;
+
+
+ /**
* Initializes a configuration from the given array.
*
* @param array $config The configuration array.
@@ -444,15 +452,37 @@ class SimpleSAML_Configuration
* @return string The absolute path relative to the root of the website.
*
* @throws SimpleSAML\Error\CriticalConfigurationError If the format of 'baseurlpath' is incorrect.
+ *
+ * @deprecated This method will be removed in SimpleSAMLphp 2.0. Please use getBasePath() instead.
*/
public function getBaseURL()
{
- $baseURL = $this->getString('baseurlpath', 'simplesaml/');
-
- if (preg_match('/^\*(.*)$/D', $baseURL, $matches)) {
+ if (!$this->deprecated_base_url_used) {
+ $this->deprecated_base_url_used = true;
+ SimpleSAML\Logger::warning(
+ "SimpleSAML_Configuration::getBaseURL() is deprecated, please use getBasePath() instead."
+ );
+ }
+ if (preg_match('/^\*(.*)$/D', $this->getString('baseurlpath', 'simplesaml/'), $matches)) {
// deprecated behaviour, will be removed in the future
return \SimpleSAML\Utils\HTTP::getFirstPathElement(false).$matches[1];
}
+ return ltrim($this->getBasePath(), '/');
+ }
+
+
+ /**
+ * Retrieve the absolute path pointing to the SimpleSAMLphp installation.
+ *
+ * The path is guaranteed to start and end with a slash ('/'). E.g.: /simplesaml/
+ *
+ * @return string The absolute path where SimpleSAMLphp can be reached in the web server.
+ *
+ * @throws SimpleSAML\Error\CriticalConfigurationError If the format of 'baseurlpath' is incorrect.
+ */
+ public function getBasePath()
+ {
+ $baseURL = $this->getString('baseurlpath', 'simplesaml/');
if (preg_match('#^https?://[^/]*(?:/(.+/?)?)?$#', $baseURL, $matches)) {
// we have a full url, we need to strip the path
@@ -462,7 +492,7 @@ class SimpleSAML_Configuration
}
return rtrim($matches[1], '/')."/";
} elseif ($baseURL === '' || $baseURL === '/') {
- // Root directory of site
+ // root directory of site
return '';
} elseif (preg_match('#^/?([^/]?.*/)#D', $baseURL, $matches)) {
// local path only