From cd19e41c364f7bb8fef3c1f4f890808114b82915 Mon Sep 17 00:00:00 2001 From: Christof Spies Date: Tue, 7 Jun 2011 14:12:59 +0200 Subject: [PATCH] Remove the GET - Parameter logintype in the given URL when the value is 'login'. This avoids login loops with OpenID server when login via GET request. --- typo3/sysext/openid/sv1/class.tx_openid_sv1.php | 48 ++++++++++++++++++++++- 1 files changed, 46 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/openid/sv1/class.tx_openid_sv1.php b/typo3/sysext/openid/sv1/class.tx_openid_sv1.php index 1c9f70a..7b54b17 100644 --- a/typo3/sysext/openid/sv1/class.tx_openid_sv1.php +++ b/typo3/sysext/openid/sv1/class.tx_openid_sv1.php @@ -370,7 +370,7 @@ class tx_openid_sv1 extends t3lib_svbase { $returnURL = $this->getReturnURL(); $trustedRoot = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); - if ($authenticationRequest->shouldSendRedirect()) { + if ($authenticationRequest->shouldSendRedirect()) { $redirectURL = $authenticationRequest->redirectURL($trustedRoot, $returnURL); // If the redirect URL can't be built, return. We can only return. @@ -404,6 +404,47 @@ class tx_openid_sv1 extends t3lib_svbase { } /** + * Remove the GET - Parameter logintype in the given URL when the value + * is 'login'. This avoids login loops with OpenID server when login + * via GET request. + * + * @param string $requestURL + * @return string + * @author Markus Kurde + * @see getReturnURL + */ + private function _remove_login_type_parameter_from_url($requestURL) + { + $urlParts = parse_url($requestURL); + $urlParts['query'] = t3lib_div::explodeUrl2Array($urlParts['query']); + + if ($urlParts['query']['logintype'] == 'login') + { + unset($urlParts['query']['logintype']); + unset($urlParts['query']['user']); + unset($urlParts['query']['pid']); + } + $urlParts['query'] = t3lib_div::implodeArrayForUrl('', $urlParts['query']); + if (function_exists('http_build_url')) + { + return http_build_url($urlParts); + } + else + { + $url = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path']; + if (!empty($urlParts['query'])) + { + $url .= '?' . $urlParts['query']; + } + if (!empty($urlParts['fragment'])) + { + $url .= '#' . $urlParts['fragment']; + } + return $url; + } + } + + /** * Creates return URL for the OpenID server. When a user is authenticated by * the OpenID server, the user will be sent to this URL to complete * authentication process with the current site. We send it to our script. @@ -434,6 +475,9 @@ class tx_openid_sv1 extends t3lib_svbase { $requestURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'); $claimedIdentifier = $this->loginData['uname']; } + + $requestURL = $this->_remove_login_type_parameter_from_url($requestURL); + $returnURL .= 'tx_openid_location=' . rawurlencode($requestURL) . '&' . 'tx_openid_mode=finish&' . 'tx_openid_claimed=' . rawurlencode($claimedIdentifier) . '&' . @@ -575,4 +619,4 @@ if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLA include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/openid/sv1/class.tx_openid_sv1.php']); } -?> \ No newline at end of file +?> -- 1.7.4.msysgit.0