From 17e63ab160b74dde508102dcbbf717f5c266e7be Mon Sep 17 00:00:00 2001
From: Jaime Perez Crespo <jaime.perez@uninett.no>
Date: Wed, 8 Jun 2016 15:07:01 +0200
Subject: [PATCH] Stop using the deprecated
 SimpleSAML_Configuration::getBaseURL() method.

---
 lib/SimpleSAML/Metadata/MetaDataStorageHandler.php | 3 +--
 lib/SimpleSAML/SessionHandlerPHP.php               | 2 +-
 lib/SimpleSAML/Utils/HTTP.php                      | 2 +-
 lib/SimpleSAML/XHTML/Template.php                  | 3 ++-
 modules/consent/lib/Consent/Store/Cookie.php       | 2 +-
 modules/core/www/authenticate.php                  | 2 +-
 modules/core/www/frontpage_federation.php          | 4 ++--
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
index 18083c27a..95b32b5fc 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php
@@ -98,8 +98,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandler
         $config = SimpleSAML_Configuration::getInstance();
         assert($config instanceof SimpleSAML_Configuration);
 
-        $baseurl = \SimpleSAML\Utils\HTTP::getSelfURLHost().'/'.
-            $config->getBaseURL();
+        $baseurl = \SimpleSAML\Utils\HTTP::getSelfURLHost().$config->getBasePath();
 
         if ($set == 'saml20-sp-hosted') {
             if ($property === 'SingleLogoutServiceBinding') {
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index eb0c7d57f..dd689d055 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -318,7 +318,7 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler
             $ret['path'] = $config->getBoolean(
                 'session.phpsession.limitedpath',
                 false
-            ) ? '/'.$config->getBaseURL() : '/';
+            ) ? $config->getBasePath() : '/';
         }
 
         $ret['httponly'] = $config->getBoolean('session.phpsession.httponly', true);
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 068a8a66e..9de34eb6f 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -581,7 +581,7 @@ class HTTP
 
             $hostname = self::getServerHost();
             $port = self::getServerPort();
-            $path = '/'.$globalConfig->getBaseURL();
+            $path = $globalConfig->getBasePath();
 
             return $protocol.$hostname.$port.$path;
         } else {
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 7cbf70939..8214ac154 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -50,7 +50,8 @@ class SimpleSAML_XHTML_Template
     {
         $this->configuration = $configuration;
         $this->template = $template;
-        $this->data['baseurlpath'] = $this->configuration->getBaseURL();
+        // TODO: do not remove the slash from the beginning, change the templates instead!
+        $this->data['baseurlpath'] = ltrim($this->configuration->getBasePath(), '/');
         $this->translator = new SimpleSAML\Locale\Translate($configuration, $defaultDictionary);
     }
 
diff --git a/modules/consent/lib/Consent/Store/Cookie.php b/modules/consent/lib/Consent/Store/Cookie.php
index 95a96bae9..8da1cbaa9 100644
--- a/modules/consent/lib/Consent/Store/Cookie.php
+++ b/modules/consent/lib/Consent/Store/Cookie.php
@@ -268,7 +268,7 @@ class sspmod_consent_Consent_Store_Cookie extends sspmod_consent_Store
         $globalConfig = SimpleSAML_Configuration::getInstance();
         $params = array(
             'lifetime' => (90*24*60*60),
-            'path' => ('/' . $globalConfig->getBaseURL()),
+            'path' => ($globalConfig->getBasePath()),
             'httponly' => FALSE,
         );
 
diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php
index b6308d36e..d71082580 100644
--- a/modules/core/www/authenticate.php
+++ b/modules/core/www/authenticate.php
@@ -14,7 +14,7 @@ $asId = (string) $_REQUEST['as'];
 $as = new SimpleSAML_Auth_Simple($asId);
 
 if (array_key_exists('logout', $_REQUEST)) {
-    $as->logout('/'.$config->getBaseURL().'logout.php');
+    $as->logout($config->getBasePath().'logout.php');
 }
 
 if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index 7b8ac2b99..35f31d432 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -78,7 +78,7 @@ if ($isadmin) {
 if ($config->getBoolean('enable.saml20-idp', FALSE) === true) {
 	try {
 		$metaentries['hosted']['saml20-idp'] = $metadata->getMetaDataCurrent('saml20-idp-hosted');
-		$metaentries['hosted']['saml20-idp']['metadata-url'] = '/' . $config->getBaseURL() .
+		$metaentries['hosted']['saml20-idp']['metadata-url'] = $config->getBasePath() .
                                                                'saml2/idp/metadata.php?output=xhtml';
 		if ($isadmin)
 			$metaentries['remote']['saml20-sp-remote'] = $metadata->getList('saml20-sp-remote');
@@ -87,7 +87,7 @@ if ($config->getBoolean('enable.saml20-idp', FALSE) === true) {
 if ($config->getBoolean('enable.shib13-idp', FALSE) === true) {
 	try {
 		$metaentries['hosted']['shib13-idp'] = $metadata->getMetaDataCurrent('shib13-idp-hosted');
-		$metaentries['hosted']['shib13-idp']['metadata-url'] = '/' . $config->getBaseURL() .
+		$metaentries['hosted']['shib13-idp']['metadata-url'] = $config->getBasePath() .
                                                                'shib13/idp/metadata.php?output=xhtml';
 		if ($isadmin)
 			$metaentries['remote']['shib13-sp-remote'] = $metadata->getList('shib13-sp-remote');
-- 
GitLab