/** * Builds a proper login link for the given method object. * * @param $methodName * the method name to use for login * @return String * properly built login link for the given method */ private function buildLink($methodName) { $method = $this->multiAuthPlugin->getMethod($methodName); $link = $method['login']; $link_href = $link['href']; if (strstr($link_href, '{RETURN_URL}')) { $return_url = $this->buildReturnURL($methodName); $link_href = str_replace('{RETURN_URL}', wfUrlencode($return_url), $link_href); } return $link_href; }
/** * Builds a list of all activated methods and their respective login * links and texts. * The list is stored within the object. */ private function buildLinkList() { // get a list of all the activated method names $activatedMethods = $this->multiAuthPlugin->getActivatedMethods(); // walk all configured authentication methods foreach ($activatedMethods as $methodName => $method) { $link = $method['login']; $link_text = $link['text']; $link_href = SpecialPage::getTitleFor('MultiAuthSpecialLogin')->escapeFullURL() . '?method=' . $methodName; // configure the link $this->linkList['MA_' . $methodName . '_Login'] = array('text' => $link_text, 'href' => $link_href); } }
private function buildReturnURL($methodName) { if (!$this->multiAuthPlugin->getCurrentAuthLib() == 'shibboleth' || !isset($currentMethod['auth']['mode']) || $currentMethod['auth']['mode'] == 'lazy') { // we can come back to MW $local_href = SpecialPage::getTitleFor('MultiAuthSpecialLogout')->escapeFullURL(); } else { // we won't be able to come back to MW because of access restrictions $local_href = isset($currentMethod['auth']['strictLogoutTarget']) ? $currentMethod['auth']['strictLogoutTarget'] : ''; } $return_url = $local_href; if (strstr($return_url, '{RETURN_URL}') && isset($_REQUEST['returnto'])) { $return_url = str_replace('{RETURN_URL}', $_REQUEST['returnto'], $return_url); } return $return_url; }
/** * Builds a proper login link for the given method object. * * @param $methodName * the method name to use for login * @return String * properly built login link for the given method */ private function buildLink($methodName) { $method = $this->multiAuthPlugin->getMethod($methodName); $link = $method['login']; $link_href = $link['href']; if (strstr($link_href, '{RETURN_URL}')) { if ($methodName == 'local') { $return_url = isset($_REQUEST['returnto']) ? $_REQUEST['returnto'] : ''; } else { $returnto = isset($_REQUEST['returnto']) ? '?returnto=' . $_REQUEST['returnto'] : ''; $return_url = SpecialPage::getTitleFor('MultiAuthSpecialLogin')->escapeFullURL() . $returnto; } $link_href = str_replace('{RETURN_URL}', wfUrlencode($return_url), $link_href); } return $link_href; }
/** * Initiates a two-stage logout process. * At first the external logout URL is called for external logout. * After return to this logout page a local logout is performed additionally. * @param string $html the variable containing the HTML code for the page */ private function doExternalLogout(&$html) { global $wgUser; $oldName = $wgUser->getName(); // prepare data for external logout $currentMethod = $this->multiAuthPlugin->getCurrentMethod(); $link = $currentMethod['logout']; $link_text = $link['text']; $link_href = $link['href']; if ($this->multiAuthPlugin->config['internal']['authMode'] == 'lazy') { // we can come back to MW $local_href = SpecialPage::getTitleFor('MultiAuthSpecialLogout')->escapeLocalURL(); } else { // we won't be able to come back to MW because of access restrictions $local_href = isset($this->multiAuthPlugin->config['internal']['strictLogoutTarget']) ? $this->multiAuthPlugin->config['internal']['strictLogoutTarget'] : ''; } // build the logout url if (strstr($link_href, '{RETURN_URL}')) { $return_url = $local_href; if (strstr($return_url, '{RETURN_URL}') && isset($_REQUEST['returnto'])) { $return_url = str_replace('{RETURN_URL}', $_REQUEST['returnto'], $return_url); } $link_href = str_replace('{RETURN_URL}', wfUrlencode($return_url), $link_href); } // first: local $success = $this->multiAuthPlugin->logout(); if ($success) { // finish off the local logout wfRunHooks('UserLogoutComplete', array(&$wgUser, &$injectedHtml, $oldName)); // second: external wfDebugLog('MultiAuthPlugin', __METHOD__ . ': ' . "Initiating external logout process (" . $link_href . ")."); header("Location: " . $link_href); exit; // no execution past here! } else { $html .= "<p>" . wfMsg('msg_logoutFailure') . "</p>\n"; return false; } }