diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index 2c035bc7415782deb95931da13babcafe9ee13e9..a276d8f3059db3addc6224a66091d1d1298d6acd 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -226,7 +226,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception { 'exceptionTrace' => $etrace, 'reportId' => $reportId, 'trackId' => $session->getTrackID(), - 'url' => SimpleSAML_Utilities::selfURLNoQuery(), + 'url' => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), 'version' => $config->getVersion(), 'referer' => $referer, ); diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 44f2ff14c8257c95171c7332057b02b94b99a847..d96f71a45def7e98e2b343c4f8fc943da259c1e2 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -66,16 +66,10 @@ class SimpleSAML_Utilities { /** - * Will return https://sp.example.org/universities/ruc/baz/simplesaml/saml2/SSOService.php + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfURLNoQuery() instead. */ public static function selfURLNoQuery() { - - $selfURLhost = self::selfURLhost(); - $selfURLhost .= $_SERVER['SCRIPT_NAME']; - if (isset($_SERVER['PATH_INFO'])) { - $selfURLhost .= $_SERVER['PATH_INFO']; - } - return $selfURLhost; + return \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(); } diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index eed837a28dc6cc3e83eb282d8624cfeaf48a5e38..17340a0b8e8d21faf79b94db258a387bb760c312 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -372,16 +372,16 @@ class HTTP /** - * Retrieve the current URL. + * Retrieve the current, complete URL. * - * @return string The current URL. + * @return string The current URL, including query parameters. * * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ public static function getSelfURL() { - $selfURLhost = self::getSelfURLHost(); + $url = self::getSelfURLHost(); $requestURI = $_SERVER['REQUEST_URI']; if ($requestURI[0] !== '/') { // we probably have a URL of the form: http://server/ @@ -389,7 +389,7 @@ class HTTP $requestURI = $matches[1]; } } - return $selfURLhost.$requestURI; + return $url.$requestURI; } @@ -410,6 +410,24 @@ class HTTP } + /** + * Retrieve the current URL without the query parameters. + * + * @return string The current URL, not including query parameters. + * + * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> + */ + public static function getSelfURLNoQuery() + { + $url = self::getSelfURLHost(); + $url .= $_SERVER['SCRIPT_NAME']; + if (isset($_SERVER['PATH_INFO'])) { + $url .= $_SERVER['PATH_INFO']; + } + return $url; + } + + /** * Parse a query string into an array. * diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 87e7db3d3fe9ce0cc66109a1dde935f7eddb52c3..f423ca7100fdc10cbdffa62985ab22245c3dce1b 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -523,7 +523,7 @@ class SimpleSAML_XHTML_IdPDisco { $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['entityID'] = $this->spEntityId; - $t->data['urlpattern'] = htmlspecialchars(SimpleSAML_Utilities::selfURLNoQuery()); + $t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); $t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', FALSE); $t->show(); } diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index e4e58a4f377b7bebb5f210630b883e8917fe0b83..3b95150254ba731fec4741afd0f95b491c890438 100644 --- a/modules/adfs/www/idp/metadata.php +++ b/modules/adfs/www/idp/metadata.php @@ -134,7 +134,7 @@ try { $t->data['available_certs'] = $availableCerts; $t->data['header'] = 'adfs-idp'; - $t->data['metaurl'] = SimpleSAML_Utilities::selfURLNoQuery(); + $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(); $t->data['metadata'] = htmlspecialchars($metaxml); $t->data['metadataflat'] = htmlspecialchars($metaflat); $t->data['defaultidp'] = $defaultidp; diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php index 0e23193c1dbe3dd9f3eee6735426f6493355e67d..606095058973964e330e958c721106c326cb2c5e 100644 --- a/modules/core/www/authenticate.php +++ b/modules/core/www/authenticate.php @@ -53,6 +53,6 @@ $t->data['header'] = '{status:header_saml20_sp}'; $t->data['attributes'] = $attributes; // if saml:sp:IdP is set, this is SAML auth so we can pass a NameId $t->data['nameid'] = !is_null( $as->getAuthData('saml:sp:IdP') ) ? $as->getAuthData('saml:sp:NameID') : FALSE; -$t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?as=' . urlencode($asId) . '&logout'; +$t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery() . '?as=' . urlencode($asId) . '&logout'; $t->show(); diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index ef50dc6e0db801c13d4070e07c54345910081472..aaed123b69c9eabcb45e2231f66fd6f847d1f909 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -224,7 +224,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['entityID'] = $this->spEntityId; - $t->data['urlpattern'] = htmlspecialchars(SimpleSAML_Utilities::selfURLNoQuery()); + $t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); $t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', FALSE); $t->data['rememberchecked'] = $this->config->getBoolean('idpdisco.rememberchecked', FALSE); $t->data['defaulttab'] = $this->discoconfig->getValue('defaulttab', 0); diff --git a/modules/oauth/www/authorize.php b/modules/oauth/www/authorize.php index 17392ad73138aed811e74ec629cb5ab332fda179..9ff13dc3d0a48a1159d6782cac932bb2811e5dc9 100644 --- a/modules/oauth/www/authorize.php +++ b/modules/oauth/www/authorize.php @@ -41,7 +41,7 @@ try { $t->data['header'] = '{status:header_saml20_sp}'; $t->data['consumer'] = $consumer; // array containint {name, description, key, secret, owner} keys $t->data['urlAgree'] = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURL(), array("consent" => "yes")); - $t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?logout'; + $t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery() . '?logout'; $t->show(); @@ -70,7 +70,7 @@ try { $t->data['header'] = '{status:header_saml20_sp}'; $t->data['remaining'] = $session->getAuthData($as, "Expire") - time(); $t->data['attributes'] = $attributes; - $t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?logout'; + $t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery() . '?logout'; $t->data['oauth_verifier'] = $verifier; $t->show(); } diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index e8e5a8b8d972c692ead4237397af05885ec290df..936bdbadaeefd3169f654b0d3ac6b4040de9a67b 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -362,7 +362,7 @@ class sspmod_saml_IdP_SAML2 { } $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters( - SimpleSAML_Utilities::selfURLNoQuery(), + \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), $sessionLostParams); $state = array( diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index 1e85687ad35e9c48f7d1c47943a559f79d22e098..13532c047b9c9a817d6f4cecfc0c94beedb9338b 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -500,7 +500,7 @@ class sspmod_saml_Message { } /* Validate Response-element destination. */ - $currentURL = SimpleSAML_Utilities::selfURLNoQuery(); + $currentURL = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(); $msgDestination = $response->getDestination(); if ($msgDestination !== NULL && $msgDestination !== $currentURL) { throw new Exception('Destination in response doesn\'t match the current URL. Destination is "' . @@ -556,7 +556,7 @@ class sspmod_saml_Message { } /* At least one valid signature found. */ - $currentURL = SimpleSAML_Utilities::selfURLNoQuery(); + $currentURL = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(); /* Check various properties of the assertion. */ diff --git a/modules/saml/www/sp/saml2-logout.php b/modules/saml/www/sp/saml2-logout.php index 1c5d87546bf4897faae1b9534111c92badd4e387..637009ac4820c2e336b6e15660f01dae49549971 100644 --- a/modules/saml/www/sp/saml2-logout.php +++ b/modules/saml/www/sp/saml2-logout.php @@ -48,7 +48,7 @@ $spMetadata = $source->getMetadata(); sspmod_saml_Message::validateMessage($idpMetadata, $spMetadata, $message); $destination = $message->getDestination(); -if ($destination !== NULL && $destination !== SimpleSAML_Utilities::selfURLNoQuery()) { +if ($destination !== NULL && $destination !== \SimpleSAML\Utils\HTTP::getSelfURLNoQuery()) { throw new SimpleSAML_Error_Exception('Destination in logout message is wrong.'); } diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php index 142cf16bf90082cb2fac146657db7832dcd7682b..51c2a80a4c227c55b7cf4113c75b85c98c6efcfd 100644 --- a/www/admin/hostnames.php +++ b/www/admin/hostnames.php @@ -19,7 +19,7 @@ $attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']); $attributes['Utilities_getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL()); $attributes['Utilities_getSelfHost()'] = array(\SimpleSAML\Utils\HTTP::getSelfHost()); $attributes['Utilities_selfURLhost()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLHost()); -$attributes['Utilities_selfURLNoQuery()'] = array(SimpleSAML_Utilities::selfURLNoQuery()); +$attributes['Utilities_selfURLNoQuery()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); $attributes['Utilities_getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath()); $attributes['Utilities_getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement()); $attributes['Utilities_selfURL()'] = array(\SimpleSAML\Utils\HTTP::getSelfURL()); diff --git a/www/errorreport.php b/www/errorreport.php index a0f31e1a5800e092b20fe6f20313d94b67fea01c..3e92b1804e160bef5ad58e1bd387bd824bc5b67c 100644 --- a/www/errorreport.php +++ b/www/errorreport.php @@ -99,4 +99,4 @@ if ($config->getBoolean('errorreporting', TRUE) && $toAddress !== 'na@example.or } /* Redirect the user back to this page to clear the POST request. */ -SimpleSAML_Utilities::redirectTrustedURL(SimpleSAML_Utilities::selfURLNoQuery()); +SimpleSAML_Utilities::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index 6f7377cfe88b6c27892d6649cf4f697b3cfd3270..d78aefbb7def5ef7fbd1b5b5f626c54c60673312 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -191,7 +191,7 @@ try { $t->data['available_certs'] = $availableCerts; $t->data['header'] = 'saml20-idp'; - $t->data['metaurl'] = SimpleSAML_Utilities::selfURLNoQuery(); + $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(); $t->data['metadata'] = htmlspecialchars($metaxml); $t->data['metadataflat'] = htmlspecialchars($metaflat); $t->data['defaultidp'] = $defaultidp; diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php index 92eb4ec05119d3036757f9f1c66ccf46165ee492..73234215d22a8eae46b1be445378711d96f5ef73 100644 --- a/www/shib13/idp/metadata.php +++ b/www/shib13/idp/metadata.php @@ -87,7 +87,7 @@ try { $t->data['header'] = 'shib13-idp'; - $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xml')); + $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::addURLParameters(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), array('output' => 'xml')); $t->data['metadata'] = htmlspecialchars($metaxml); $t->data['metadataflat'] = htmlspecialchars($metaflat);