summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
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