Set the logout URL of the CAS server.
public static setServerLogoutURL ( string $url = '' ) : void | ||
$url | string | the logout URL |
return | void |
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * * @since version 0.85 in front */ include '../inc/includes.php'; //@session_start(); if (!isset($_SESSION["noAUTO"]) && isset($_SESSION["glpiauthtype"]) && $_SESSION["glpiauthtype"] == Auth::CAS) { include GLPI_PHPCAS; phpCAS::client(CAS_VERSION_2_0, $CFG_GLPI["cas_host"], intval($CFG_GLPI["cas_port"]), $CFG_GLPI["cas_uri"], false); phpCAS::setServerLogoutURL(strval($CFG_GLPI["cas_logout"])); phpCAS::logout(); } $toADD = ""; // Redirect management if (isset($_POST['redirect']) && strlen($_POST['redirect']) > 0) { $toADD = "?redirect=" . $_POST['redirect']; } else { if (isset($_GET['redirect']) && strlen($_GET['redirect']) > 0) { $toADD = "?redirect=" . $_GET['redirect']; } } if (isset($_SESSION["noAUTO"]) || isset($_GET['noAUTO'])) { if (empty($toADD)) { $toADD .= "?"; } else {
if (DEBUG_PHPCAS) { if (HEBERGEUR_INSTALLATION == 'mono-structure' || !PHPCAS_ETABL_ID_LISTING || strpos(PHPCAS_ETABL_ID_LISTING, ',' . $BASE . ',') !== FALSE) { $fichier_nom_debut = 'debugcas_' . $BASE; $fichier_nom_fin = fabriquer_fin_nom_fichier__pseudo_alea($fichier_nom_debut); phpCAS::setDebug(PHPCAS_CHEMIN_LOGS . $fichier_nom_debut . '_' . $fichier_nom_fin . '.txt'); } } // Initialiser la connexion avec CAS ; le premier argument est la version du protocole CAS ; le dernier argument indique qu'on utilise la session existante phpCAS::client(CAS_VERSION_2_0, $cas_serveur_host, (int) $cas_serveur_port, $cas_serveur_root, FALSE); phpCAS::setLang(PHPCAS_LANG_FRENCH); // Surcharge éventuelle des URL if ($cas_serveur_url_login) { phpCAS::setServerLoginURL($cas_serveur_url_login); } if ($cas_serveur_url_logout) { phpCAS::setServerLogoutURL($cas_serveur_url_logout); } if ($cas_serveur_url_validate) { phpCAS::setServerServiceValidateURL($cas_serveur_url_validate); } // Suite à des attaques DDOS, Kosmos a décidé en avril 2015 de filtrer les requêtes en bloquant toutes celles sans User-Agent. // C'est idiot car cette valeur n'est pas fiable, n'importe qui peut présenter n'importe quel User-Agent ! // En attendant qu'ils appliquent un remède plus intelligent, et au cas où un autre prestataire aurait la même mauvaise idée, on envoie un User-Agent bidon (défini dans le loader)... phpCAS::setExtraCurlOption(CURLOPT_USERAGENT, CURL_AGENT); // Appliquer un proxy si défini par le webmestre ; voir cURL::get_contents() pour les commentaires. if (defined('SERVEUR_PROXY_USED') && SERVEUR_PROXY_USED) { phpCAS::setExtraCurlOption(CURLOPT_PROXY, SERVEUR_PROXY_NAME); phpCAS::setExtraCurlOption(CURLOPT_PROXYPORT, (int) SERVEUR_PROXY_PORT); phpCAS::setExtraCurlOption(CURLOPT_PROXYTYPE, constant(SERVEUR_PROXY_TYPE)); if (SERVEUR_PROXY_AUTH_USED) { phpCAS::setExtraCurlOption(CURLOPT_PROXYAUTH, constant(SERVEUR_PROXY_AUTH_METHOD));
/** * Initialize CAS client * */ private function cas_init() { if (!$this->cas_inited) { // retrieve configurations $cfg = rcmail::get_instance()->config->all(); // include phpCAS require_once('/usr/share/php/CAS/CAS.php'); phpCAS::setDebug('/var/log/lcs/casdebug.log'); // initialize CAS client if ($cfg['cas_proxy']) { phpCAS::proxy(CAS_VERSION_2_0, $cfg['cas_hostname'], $cfg['cas_port'], $cfg['cas_uri'], false); // set URL for PGT callback phpCAS::setFixedCallbackURL($this->generate_url(array('action' => 'pgtcallback'))); // set PGT storage #phpCAS::setPGTStorageFile('xml', $cfg['cas_pgt_dir']); phpCAS::setPGTStorageFile($cfg['cas_pgt_dir']); } else { phpCAS::client(CAS_VERSION_2_0, $cfg['cas_hostname'], $cfg['cas_port'], $cfg['cas_uri'], false); } // set service URL for authorization with CAS server phpCAS::setFixedServiceURL($this->generate_url(array('action' => 'login', 'task' => 'mail'))); // set SSL validation for the CAS server if ($cfg['cas_validation'] == 'self') { phpCAS::setCasServerCert($cfg['cas_cert']); } else if ($cfg['cas_validation'] == 'ca') { phpCAS::setCasServerCACert($cfg['cas_cert']); } else { phpCAS::setNoCasServerValidation(); } // set login and logout URLs of the CAS server phpCAS::setServerLoginURL($cfg['cas_login_url']); phpCAS::setServerLogoutURL($cfg['cas_logout_url']); $this->cas_inited = true; } }
private function _logout() { $logoutOpt = array('url' => $this->cfg['domain']); phpCAS::setServerLogoutURL($this->cfg['logoutUrl']); phpCAS::logout($logoutOpt); }
/** * @todo make this options usable. * @todo move to other class * * @param string $providerName defined in Settings.yaml * * @throws \TYPO3\Flow\Exception * * @return void */ private function setOptionalClientSettings($providerName) { $casClientSettings = $this->getClientSettingsByProviderName($providerName); try { if (!empty($casClientSettings['serverLoginURL'])) { \phpCAS::setServerLoginURL($casClientSettings['serverLoginURL']); } if (!empty($casClientSettings['serverLogoutURL'])) { \phpCAS::setServerLogoutURL($casClientSettings['serverLogoutURL']); } if (!empty($casClientSettings['serverProxyValidateURL'])) { \phpCAS::setServerProxyValidateURL($casClientSettings['serverProxyValidateURL']); } if (!empty($casClientSettings['serverSamlValidateURL'])) { \phpCAS::setServerSamlValidateURL($casClientSettings['serverSamlValidateURL']); } if (!empty($casClientSettings['serverServiceValidateURL'])) { \phpCAS::setServerServiceValidateURL($casClientSettings['serverServiceValidateURL']); } // since CAS 4.0 disbled if (!empty($casClientSettings['singleSignoutCallback'])) { \phpCAS::setSingleSignoutCallback($casClientSettings['singleSignoutCallback']); } } catch (\Exception $exc) { throw new \TYPO3\Flow\Exception('Can not set some optianal property in Jasigs phpCAS broken on: ' . $exc->getCode() . ' with message: ' . $exc->getMessage(), 1372519681); } }
/** * Returns the URL to logout of the CAS server. * * @param string $service The service url requesting logout. * * @return string */ public function setLogoutUrl($url = '') { if (empty($url)) { $url = $this->getUrl(); $url .= substr($url, -1) == '/' ? 'logout?' : '/logout?'; $queryParams = array($this->getServiceParam() => $this->getService(), "ssokey" => $this->getApiKey(), "extraParams" => $this->getExtraParams(), "sign" => $this->getSign(), "source" => $this->getSource(), 'redirect_uri' => $this->getRedirectUri()); $url .= http_build_query($queryParams); } $this->_logoutUrl = $url; phpCAS::setServerLogoutURL($this->_logoutUrl); }