From da93d7c4eda0c35d0521bdc76febdeba18e5190a Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 28 Aug 2009 07:47:12 +0000 Subject: [PATCH] SimpleSAML_Utilities: Add getBaseURL function. This function returns the absolute URL to the base of the simpleSAMLphp installation, and should be used instead of: SimpleSAML_Utilities::selfURLhost() . '/' . $config->getBaseURL() git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1723 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Utilities.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 601ff46ca..e0140a056 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -152,6 +152,29 @@ class SimpleSAML_Utilities { } + /** + * Retrieve the absolute base URL for the simpleSAMLphp installation. + * + * This function will 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. + */ + public static function getBaseURL() { + + $globalConfig = SimpleSAML_Configuration::getInstance(); + $ret = SimpleSAML_Utilities::selfURLhost() . '/' . $globalConfig->getBaseURL(); + if (substr($ret, -1) !== '/') { + throw new SimpleSAML_Error_Exception('Invalid value of \'baseurl\' in ' . + 'config.php. It must end with a \'/\'.'); + } + + return $ret; + } + + /** * Add one or more query parameters to the given URL. * -- GitLab