logoutWithRedirectService() public static method

This method is used to logout from CAS. Halts by redirecting to the CAS server.
public static logoutWithRedirectService ( string $service ) : void
$service string a URL that will be transmitted to the CAS server
return void
Esempio n. 1
0
 public static function logout($parameters)
 {
     if (phpCAS::isAuthenticated()) {
         phpCAS::logoutWithRedirectService(OC::$server->getURLGenerator()->getAbsoluteURL(""));
     }
     return true;
 }
Esempio n. 2
0
function checkAndSetUserSession()
{
    // store session data
    if (!isset($_SESSION['user'])) {
        $_SESSION['user'] = null;
    }
    if (isset($_REQUEST['login']) or isset($_REQUEST['logout'])) {
        // initialize phpCAS
        phpCAS::client(CAS_VERSION_2_0, 'login.kth.se', 443, '');
        //phpCAS::proxy(CAS_VERSION_2_0,'login.kth.se',443,'');
        phpCAS::setNoCasServerValidation();
        // If you want the redirect back from the login server to enter your application by some
        // specfic URL rather than just back to the current request URI, call setFixedCallbackURL.
        //phpCAS::setFixedCallbackURL('http://xml.csc.kth.se/~wiiala/DM2517/project/php/index.php');
        // force CAS authentication
        phpCAS::forceAuthentication();
        // at this step, the user has been authenticated by the CAS server
        // and the user's login name can be read with phpCAS::getUser().
        $_SESSION['user'] = phpCAS::getUser();
        //Logga ut och redirecta till vår standardsida
        if (isset($_REQUEST['logout'])) {
            unset($_SESSION['user']);
            phpCAS::logoutWithRedirectService('http://kth.kribba.com/');
        }
    }
}
Esempio n. 3
0
 /**
  *  Logout and redirect to the main site URL,
  *  or to the URL passed as argument.
  */
 public function logout($url = '')
 {
     if (empty($url)) {
         $this->CI->load->helper('url');
         $url = base_url();
     }
     phpCAS::logoutWithRedirectService($url);
 }
Esempio n. 4
0
 /**
  * Destroy the user session
  */
 public function logout()
 {
     $errorReporting = ini_get('error_reporting');
     error_reporting($errorReporting & ~E_STRICT & ~E_NOTICE);
     $this->initCasClient();
     phpCAS::logoutWithRedirectService('http://' . $_SERVER['HTTP_HOST'] . url_for('/'));
     // FIXME remove plain "http"
     error_reporting($errorReporting);
 }
Esempio n. 5
0
 public static function signOut($config, $return_url = null)
 {
     self::buildClient($config->get('cas-hostname'), $config->get('cas-port'), $config->get('cas-context'));
     unset($_SESSION[':cas']);
     if ($config->get('cas-single-sign-off')) {
         if (empty($return_url)) {
             phpCAS::logout();
         } else {
             phpCAS::logoutWithRedirectService($return_url);
         }
     }
 }
Esempio n. 6
0
 public function executeLogout(sfWebRequest $request)
 {
     $this->getContext()->getUser()->signOut();
     error_reporting(ini_get('error_reporting') & ~E_STRICT & ~E_NOTICE);
     if (sfConfig::get('app_cas_server_host')) {
         // Le filtre uapvSecurityFilterCas n'ayant pas forcément été déclanché
         // on force l'appel phpCas::client()
         phpCAS::client(sfConfig::get('app_cas_server_version', CAS_VERSION_2_0), sfConfig::get('app_cas_server_host', 'localhost'), sfConfig::get('app_cas_server_port', 443), sfConfig::get('app_cas_server_path', ''), false);
         // Don't call session_start again,
         // symfony already did it
         // Redirection vers le CAS
         phpCAS::logoutWithRedirectService($request->getParameter('redirect', $this->getContext()->getController()->genUrl('@homepage', true)));
     } else {
         $this->redirect('@homepage', true);
     }
 }
Esempio n. 7
0
 /**
  * Log out the user from CAS, and redirect to given URL.
  *
  * Note that the PHP session for the current script will be completely cleared:
  * any other sesison won't be available anymore.
  *
  * @param string|bool $redirect
  * @throws \RuntimeException
  */
 public function logout($redirect = false)
 {
     // Destroy current session
     $_SESSION = array();
     if (ini_get('session.use_cookies')) {
         $params = session_get_cookie_params();
         setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     }
     // Log out from CAS
     if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') {
         $method = 'http';
     } else {
         $method = 'https';
     }
     if (!$redirect) {
         $redirect = $this->getDomainName();
         if (!$redirect) {
             throw new \RuntimeException('Redirection URL automatic detection failed. You have to provide the reciredtion URL in ' . __CLASS__ . '::' . __METHOD__);
         }
     }
     return \phpCAS::logoutWithRedirectService($method . '://' . $redirect);
 }
Esempio n. 8
0
if ($bPortal) {
    $sUrl .= 'portal/';
} else {
    $sUrl .= 'pages/UI.php';
}
if (isset($_SESSION['auth_user'])) {
    $sAuthUser = $_SESSION['auth_user'];
    UserRights::Login($sAuthUser);
    // Set the user's language
}
$sLoginMode = isset($_SESSION['login_mode']) ? $_SESSION['login_mode'] : '';
LoginWebPage::ResetSession();
switch ($sLoginMode) {
    case 'cas':
        $sCASLogoutUrl = MetaModel::GetConfig()->Get('cas_logout_redirect_service');
        if (empty($sCASLogoutUrl)) {
            $sCASLogoutUrl = $sUrl;
        }
        utils::InitCASClient();
        phpCAS::logoutWithRedirectService($sCASLogoutUrl);
        // Redirects to the CAS logout page
        break;
}
$oPage = LoginWebPage::NewLoginWebPage();
$oPage->no_cache();
$oPage->DisplayLoginHeader();
$oPage->add("<div id=\"login\">\n");
$oPage->add("<h1>" . Dict::S('UI:LogOff:ThankYou') . "</h1>\n");
$oPage->add("<p><a href=\"{$sUrl}\">" . Dict::S('UI:LogOff:ClickHereToLoginAgain') . "</a></p>");
$oPage->add("</div>\n");
$oPage->output();
Esempio n. 9
0
 /**
  * @param string $user : username
  * @param bool $remote : logged out remotely (so do not redirect)
  * @param string $redir : url to redirect to. Uses home page according to prefs if empty
  * @return void : redirects to suitable homepage or redir param if not remote
  */
 function user_logout($user, $remote = false, $redir = '')
 {
     global $prefs, $logslib, $lslib, $user_cookie_site;
     $logslib->add_log('login', 'logged out');
     $userInfo = $this->get_user_info($user);
     $this->delete_user_cookie($userInfo['userId']);
     if ($remote && $prefs['feature_intertiki'] == 'y' and $prefs['feature_intertiki_sharedcookie'] == 'y' and !empty($prefs['feature_intertiki_mymaster'])) {
         include_once 'XML/RPC.php';
         $remote = $prefs['interlist'][$prefs['feature_intertiki_mymaster']];
         $remote['path'] = preg_replace('/^\\/?/', '/', $remote['path']);
         $client = new XML_RPC_Client($remote['path'], $remote['host'], $remote['port']);
         $client->setDebug(0);
         $msg = new XML_RPC_Message('intertiki.logout', array(new XML_RPC_Value($prefs['tiki_key'], 'string'), new XML_RPC_Value($user, 'string')));
         $client->send($msg);
         return;
     }
     // more local cleanup originally from tiki-logout.php
     // go offline in Live Support
     if ($prefs['feature_live_support'] == 'y') {
         global $access;
         include_once 'lib/live_support/lslib.php';
         if ($lslib->get_operator_status($user) != 'offline') {
             $lslib->set_operator_status($user, 'offline');
         }
     }
     setcookie($user_cookie_site, '', -3600, $prefs['cookie_path'], $prefs['cookie_domain']);
     /* change group home page or deactivate if no page is set */
     if (!empty($redir)) {
         $url = $redir;
     } else {
         if (($groupHome = $this->get_group_home('Anonymous')) != '') {
             $url = preg_match('/^(\\/|https?:)/', $groupHome) ? $groupHome : 'tiki-index.php?page=' . $groupHome;
         } else {
             $url = $prefs['site_tikiIndex'];
         }
     }
     // RFC 2616 defines that the 'Location' HTTP headerconsists of an absolute URI
     if (!preg_match('/^https?\\:/i', $url)) {
         global $url_scheme, $url_host, $url_port, $base_url;
         $url = (preg_match('#^/#', $url) ? $url_scheme . '://' . $url_host . ($url_port != '' ? ":{$url_port}" : '') : $base_url) . $url;
     }
     if (SID) {
         $url .= '?' . SID;
     }
     if ($prefs['auth_method'] === 'cas' && $user !== 'admin' && $user !== '' && $prefs['cas_force_logout'] === 'y') {
         phpCAS::logoutWithRedirectService($url);
     }
     unset($_SESSION['cas_validation_time']);
     unset($_SESSION[$user_cookie_site]);
     session_unset();
     session_destroy();
     if ($prefs['auth_method'] === 'ws') {
         header('Location: ' . str_replace('//', '//admin:@', $url));
         // simulate a fake login to logout the user
     } else {
         header('Location: ' . $url);
     }
     return;
 }
Esempio n. 10
0
}
$cas_url = $cas_url . $cas_context;
// Set the session-name to be unique to the current script so that the client script
// doesn't share its session with a proxied script.
// This is just useful when running the example code, but not normally.
session_name('LinkeoPersonnalisation');
// Load the CAS lib
include_once $phpcas_path . '/CAS.php';
// Uncomment to enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
if (isset($_REQUEST['logout'])) {
    //phpCAS::logout();
    phpCAS::logoutWithRedirectService("http://linkapi.linkeo.com");
}
Esempio n. 11
0
function DoLogout()
{
    //setcookie("username", "");
    //setcookie("validlogin", "false");
    session_destroy();
    setcookie('MOD_AUTH_CAS', '', time() - 1000, '/');
    if ($GLOBALS['cfg']['enablecas']) {
        //phpCAS::client(CAS_VERSION_2_0, $GLOBALS['cfg']['casserver'], intval($GLOBALS['cfg']['casport']), $GLOBALS['cfg']['cascontext']);
        phpCAS::logoutWithRedirectService($GLOBALS['cfg']['siteurl']);
        echo "You have been logged out of NiDB through CAS. <a href='login.php'>Login</a> again.";
    } else {
        DisplayLogin("You have been logged out");
    }
}
Esempio n. 12
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once '../casconnect.php';
include_once '../dbconnect.php';
include_once '../phpfunctions.php';
$onid = phpCAS::getUser();
$res = $mysqli->query("SELECT * FROM users WHERE onid = '{$onid}'");
$userrow = $res->fetch_array(MYSQLI_ASSOC);
//keep an array of elements in the user's table for easy access
if (isset($_REQUEST['logout'])) {
    phpCAS::logoutWithRedirectService('http://eecs.oregonstate.edu/education/achievements');
}
echo '<!DOCTYPE html>
	<html>
	<head>
	<title>Collaboratory Achievement Management</title>
	</head>';
?>

	<!-- Bootstrap -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="../js/bootstrap.min.js"></script>
	
	<script src="../js/sorttable.js"></script>
	
Esempio n. 13
0
/**
* Logs out the user of the cas 
* The user MUST be logged in with cas to use this function 
**/
function cas_logout()
{
    //phpCAS::logoutWithRedirectService("fmc.univ-paris5.fr");
    phpCAS::logoutWithRedirectService(api_get_path(WEB_PATH));
}
Esempio n. 14
0
 /**
  * Logout from the CAS
  *
  */
 function prelogout_hook()
 {
     global $CFG, $USER, $DB;
     if (!empty($this->config->logoutcas) && $USER->auth == $this->authtype) {
         $backurl = !empty($this->config->logout_return_url) ? $this->config->logout_return_url : $CFG->wwwroot;
         $this->connectCAS();
         // Note: Hack to stable versions to trigger the event before it redirect to CAS logout.
         $sid = session_id();
         $event = \core\event\user_loggedout::create(array('userid' => $USER->id, 'objectid' => $USER->id, 'other' => array('sessionid' => $sid)));
         if ($session = $DB->get_record('sessions', array('sid' => $sid))) {
             $event->add_record_snapshot('sessions', $session);
         }
         \core\session\manager::terminate_current();
         $event->trigger();
         phpCAS::logoutWithRedirectService($backurl);
     }
 }
Esempio n. 15
0
 /**
  * Log out of the attached external service.
  *
  * @return void
  */
 public function custom_logout()
 {
     // Grab plugin settings.
     $auth_settings = $this->get_plugin_options('single admin', 'allow override');
     // Reset option containing old error messages.
     delete_option('auth_settings_advanced_login_error');
     if (session_id() == '') {
         session_start();
     }
     $current_user_authenticated_by = get_user_meta(get_current_user_id(), 'authenticated_by', true);
     // If logged in to CAS, Log out of CAS.
     if ($current_user_authenticated_by === 'cas' && $auth_settings['cas'] === '1') {
         if (!array_key_exists('PHPCAS_CLIENT', $GLOBALS) || !array_key_exists('phpCAS', $_SESSION)) {
             // Set the CAS client configuration if it hasn't been set already.
             phpCAS::client(SAML_VERSION_1_1, $auth_settings['cas_host'], intval($auth_settings['cas_port']), $auth_settings['cas_path']);
             // Restrict logout request origin to the CAS server only (prevent DDOS).
             phpCAS::handleLogoutRequests(true, array($auth_settings['cas_host']));
         }
         if (phpCAS::isAuthenticated()) {
             phpCAS::logoutWithRedirectService(get_option('siteurl'));
         }
     }
     // If session token set, log out of Google.
     if ($current_user_authenticated_by === 'google' && array_key_exists('token', $_SESSION)) {
         $token = json_decode($_SESSION['token'])->access_token;
         // Build the Google Client.
         $client = new Google_Client();
         $client->setApplicationName('WordPress');
         $client->setClientId($auth_settings['google_clientid']);
         $client->setClientSecret($auth_settings['google_clientsecret']);
         $client->setRedirectUri('postmessage');
         // Revoke the token
         $client->revokeToken($token);
         // Remove the credentials from the user's session.
         $_SESSION['token'] = '';
     }
 }
Esempio n. 16
0
<?php

/* *********************************************************/
/* Challenger V3 : Gestion de l'organisation du Challenge **/
/* Créé par Raphaël Kichot' MOULIN *************************/
/* raphael.moulin@ecl13.ec-lyon.fr *************************/
/* *********************************************************/
/* actions/admin/logout.php ********************************/
/* Gére la déconnexion de l'administration *****************/
/* *********************************************************/
/* Dernière modification : le 20/11/14 *********************/
/* *********************************************************/
$cas = !empty($_SESSION['admin']) && $_SESSION['admin']['auth_type'] == 'cas';
unset($_SESSION['admin']);
if ($cas) {
    require DIR . 'includes/_ecl/CAS.php';
    phpCAS::client(CAS_VERSION_2_0, CONFIG_CAS_HOST, CONFIG_CAS_PORT, CONFIG_CAS_CONTEXT);
    phpCAS::setNoCasServerValidation();
    phpCAS::logoutWithRedirectService(url('', true, false));
}
//Redirection vers l'accueil
die(header('location:' . url('', false, false)));
Esempio n. 17
0
 public function logoutWithRedirectService($url)
 {
     \phpCAS::logoutWithRedirectService($url);
 }
 /**
  * Called when no user is found in iTop for the corresponding 'name'. This method
  * can create/synchronize the User in iTop with an external source (such as AD/LDAP) on the fly
  * @param string $sName The CAS authenticated user name
  * @param string $sPassword Ignored
  * @param string $sLoginMode The login mode used (cas|form|basic|url)
  * @param string $sAuthentication The authentication method used
  * @return bool true if the user is a valid one, false otherwise
  */
 public static function CheckCredentialsAndCreateUser($sName, $sPassword, $sLoginMode, $sAuthentication)
 {
     $bOk = true;
     if ($sLoginMode != 'cas') {
         return false;
     }
     // Must be authenticated via CAS
     $sCASMemberships = MetaModel::GetConfig()->Get('cas_memberof');
     $bFound = false;
     if (!empty($sCASMemberships)) {
         if (phpCAS::hasAttribute('memberOf')) {
             // A list of groups is specified, the user must a be member of (at least) one of them to pass
             $aCASMemberships = array();
             $aTmp = explode(';', $sCASMemberships);
             setlocale(LC_ALL, "en_US.utf8");
             // !!! WARNING: this is needed to have  the iconv //TRANSLIT working fine below !!!
             foreach ($aTmp as $sGroupName) {
                 $aCASMemberships[] = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $sGroupName));
                 // Just in case remove accents and spaces...
             }
             $aMemberOf = phpCAS::getAttribute('memberOf');
             if (!is_array($aMemberOf)) {
                 $aMemberOf = array($aMemberOf);
             }
             // Just one entry, turn it into an array
             $aFilteredGroupNames = array();
             foreach ($aMemberOf as $sGroupName) {
                 phpCAS::log("Info: user if a member of the group: " . $sGroupName);
                 $sGroupName = trim(iconv('UTF-8', 'ASCII//TRANSLIT', $sGroupName));
                 // Remove accents and spaces as well
                 $aFilteredGroupNames[] = $sGroupName;
                 $bIsMember = false;
                 foreach ($aCASMemberships as $sCASPattern) {
                     if (self::IsPattern($sCASPattern)) {
                         if (preg_match($sCASPattern, $sGroupName)) {
                             $bIsMember = true;
                             break;
                         }
                     } else {
                         if ($sCASPattern == $sGroupName) {
                             $bIsMember = true;
                             break;
                         }
                     }
                 }
                 if ($bIsMember) {
                     $bCASUserSynchro = MetaModel::GetConfig()->Get('cas_user_synchro');
                     if ($bCASUserSynchro) {
                         // If needed create a new user for this email/profile
                         phpCAS::log('Info: cas_user_synchro is ON');
                         $bOk = self::CreateCASUser(phpCAS::getUser(), $aMemberOf);
                         if ($bOk) {
                             $bFound = true;
                         } else {
                             phpCAS::log("User " . phpCAS::getUser() . " cannot be created in iTop. Logging off...");
                         }
                     } else {
                         phpCAS::log('Info: cas_user_synchro is OFF');
                         $bFound = true;
                     }
                     break;
                 }
             }
             if ($bOk && !$bFound) {
                 phpCAS::log("User " . phpCAS::getUser() . ", none of his/her groups (" . implode('; ', $aFilteredGroupNames) . ") match any of the required groups: " . implode('; ', $aCASMemberships));
             }
         } else {
             // Too bad, the user is not part of any of the group => not allowed
             phpCAS::log("No 'memberOf' attribute found for user " . phpCAS::getUser() . ". Are you using the SAML protocol (S1) ?");
         }
     } else {
         // No membership: no way to create the user that should exist prior to authentication
         phpCAS::log("User " . phpCAS::getUser() . ": missing user account in iTop (or iTop badly configured, Cf setting cas_memberof)");
         $bFound = false;
     }
     if (!$bFound) {
         // The user is not part of the allowed groups, => log out
         $sUrl = utils::GetAbsoluteUrlAppRoot() . 'pages/UI.php';
         $sCASLogoutUrl = MetaModel::GetConfig()->Get('cas_logout_redirect_service');
         if (empty($sCASLogoutUrl)) {
             $sCASLogoutUrl = $sUrl;
         }
         phpCAS::logoutWithRedirectService($sCASLogoutUrl);
         // Redirects to the CAS logout page
         // Will never return !
     }
     return $bFound;
 }
Esempio n. 19
0
 public function logOut($url)
 {
     phpCAS::logoutWithRedirectService($url);
     return;
 }
Esempio n. 20
0
 public function logout()
 {
     phpCAS::logoutWithRedirectService(APP_BASE_URL);
 }
Esempio n. 21
0
 /**
  * Post logout hook.
  *
  * Note: this method replace the prelogout_hook method to avoid redirect to CAS logout
  * before the event userlogout being triggered.
  *
  * @param stdClass $user clone of USER object object before the user session was terminated
  */
 public function postlogout_hook($user)
 {
     global $CFG;
     // Only redirect to CAS logout if the user is logged as a CAS user.
     if (!empty($this->config->logoutcas) && $user->auth == $this->authtype) {
         $backurl = !empty($this->config->logout_return_url) ? $this->config->logout_return_url : $CFG->wwwroot;
         $this->connectCAS();
         phpCAS::logoutWithRedirectService($backurl);
     }
 }
Esempio n. 22
0
 function process_logout()
 {
     $not_using_cas = isset($_SESSION['not_using_CAS']) && $_SESSION['not_using_CAS'] == true;
     session_destroy();
     if ($not_using_cas) {
         wp_redirect(home_url());
     } else {
         phpCAS::logoutWithRedirectService(get_option('siteurl'));
     }
     exit;
 }
Esempio n. 23
0
    }
    
    // include HubridAuth libraries
    require_once 'modules/auth/methods/hybridauth/config.php';
	require_once 'modules/auth/methods/hybridauth/Hybrid/Auth.php';
	$config = get_hybridauth_config();
    $hybridauth = new Hybrid_Auth( $config );
    $hybridauth->logoutAllProviders();
    
    session_destroy();
    $uid = 0;
    if (defined('CAS')) {
        $cas = get_auth_settings(7);
        if (isset($cas['cas_ssout']) and intval($cas['cas_ssout']) === 1) {
            phpCAS::client(SAML_VERSION_1_1, $cas['cas_host'], intval($cas['cas_port']), $cas['cas_context'], FALSE);
            phpCAS::logoutWithRedirectService($urlServer);
        }
    }
}

// if the user logged in include the correct language files
// in case he has a different language set in his/her profile
if (isset($language)) {
    // include_messages
    include "lang/$language/common.inc.php";
    $extra_messages = "config/{$language_codes[$language]}.inc.php";
    if (file_exists($extra_messages)) {
        include $extra_messages;
    } else {
        $extra_messages = false;
    }
Esempio n. 24
0
 /**
  * @Route("/user/disconnect", name="user_disconnect")
  */
 public function disconnectAction()
 {
     if (!$this->getUserLayer()->isConnected()) {
         return $this->redirect($this->generateUrl('homepage'));
     }
     if ($this->getUserLayer()->isConnected()) {
         /** @var EntityManager $em */
         $em = $this->getDoctrine()->getManager();
         $query = $em->createQueryBuilder()->delete()->from('EtuUserBundle:Session', 's')->where('s.entityType = :type')->andWhere('s.entityId = :id')->setParameter('id', $this->getUser()->getId());
         if ($this->getUserLayer()->isOrga()) {
             $query->setParameter('type', Session::TYPE_ORGA);
         } else {
             $query->setParameter('type', Session::TYPE_USER);
         }
         $query->getQuery()->execute();
     }
     setcookie(md5('etuutt-session-cookie-name'), '', time() - 10, '/');
     $this->get('session')->set('orga', null);
     $this->get('session')->set('user', null);
     $this->get('session')->clear();
     if (ini_get('session.use_cookies')) {
         $params = session_get_cookie_params();
         setcookie(session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     }
     $this->initializeCAS();
     \phpCAS::setNoCasServerValidation();
     \phpCAS::logoutWithRedirectService('http://' . $this->container->getParameter('etu.domain'));
     return $this->redirect($this->generateUrl('homepage'));
 }
Esempio n. 25
0
// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($global_config['config_sso']['cas_certificate_path']);
// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();
// set the language to french
//phpCAS::setLang(PHPCAS_LANG_FRENCH);
phpCAS::handleLogoutRequests(false);
// https://wiki.jasig.org/display/casum/single+sign+out#SingleSignOut-Howitworks
// force CAS authentication
phpCAS::forceAuthentication();
// logout if desired
if (defined('CAS_LOGOUT_URL_REDIRECT')) {
    phpCAS::logoutWithRedirectService(CAS_LOGOUT_URL_REDIRECT);
}
$username = phpCAS::getUser();
if (!empty($username)) {
    if (nv_function_exists('ldap_connect')) {
        $ldapconn = ldap_connect($global_config['config_sso']['ldap_host_url']);
        ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, $global_config['config_sso']['ldap_version']);
        ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
        if (!empty($global_config['config_sso']['ldap_bind_dn']) and !empty($global_config['config_sso']['ldap_bind_pw'])) {
            $ldapbind = ldap_bind($ldapconn, $global_config['config_sso']['ldap_bind_dn'], $global_config['config_sso']['ldap_bind_pw']);
        } else {
            $ldapbind = ldap_bind($ldapconn);
        }
        if ($ldapbind) {
            // verify binding
            $result = ldap_search($ldapconn, $global_config['config_sso']['user_contexts'], '(uid=' . $username . ')');
Esempio n. 26
0
 public function logOff()
 {
     global $QUERY;
     if ($this->_getOption('caslogout')) {
         // dokuwiki + cas logout
         @session_start();
         session_destroy();
         $logout_url = DOKU_URL . 'doku.php?id=' . $QUERY;
         phpCAS::logoutWithRedirectService($logout_url);
     } else {
         // dokuwiki logout only
         @session_start();
         session_destroy();
         unset($_SESSION['phpCAS']);
     }
 }
Esempio n. 27
0
/**
 * Logs out the user of the cas
 * The user MUST be logged in with cas to use this function
 *
 * @param $uinfo array user info (not needed)
 * @param $location string redirect url
 *
 * @see online_logout()
 */
function cas_logout($uinfo = null, $location = null)
{
    global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
    global $PHPCAS_CLIENT;
    if (!is_object($PHPCAS_CLIENT)) {
        phpCAS::client($cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri);
        phpCAS::setNoCasServerValidation();
    }
    if (!isset($location)) {
        $location = api_get_path(WEB_PATH);
    }
    phpCAS::logoutWithRedirectService($location);
}
Esempio n. 28
0
<?php

require_once 'class/utilisateur.class.php';
//Varibale commune
$user = null;
if (!Utilisateur::isConnected()) {
    include "authCas.inc.php";
}
try {
    $user = Utilisateur::createFromSession();
} catch (Exception $e) {
    echo $e->getMessage();
    exit;
}
if (isset($_REQUEST['logout'])) {
    if (isset($_SESSION['phpCAS'])) {
        require_once "CAS-1.3.4/CAS.php";
        require_once "config.php";
        // Enable debugging
        phpCAS::setDebug();
        // Initialize phpCAS
        phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context, false);
        // no SSL validation for the CAS server
        phpCAS::setNoCasServerValidation();
        phpCAS::logoutWithRedirectService("http://localhost/www/GestionnaireStage/index.php");
    } else {
        Utilisateur::logoutIfRequested();
        header("Location: index.php");
        exit;
    }
}
Esempio n. 29
0
<?php

require_once "./cas/phpCAS-master/CAS.php";
require_once "config.example.php";
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
phpCAS::setNoCasServerValidation();
if (isset($_REQUEST['logout'])) {
    $_SESSION['cas'] = "yes";
    phpCAS::logoutWithRedirectService("https://osr-etudiant.unistra.fr/~r.henry/aCalendar/");
}
if (phpCAS::checkAuthentication()) {
    $_SESSION['user'] = phpCas::getUser();
    $_SESSION['cas'] = "yes";
    header('Location: ../index.php');
} else {
    phpCAS::forceAuthentication();
}
//echo phpCAS::logoutWithRedirectService('inscription.php');
//
?>
<!--<!<?php 
//if (isset($erreur)) echo '<br /><br />',$erreur;
//if(isset($_POST['connexion']) && $_POST['connexion'] == 'Connexion'){
//if((isset($_POST['login']) && isset($_POST['pass'])) && (!empty($_POST['login']) && !empty($_POST['pass'])))
//{
//$base = new PDO('mysql:host=localhost;dbname=test', 'root', '') ;
//or die("Erreur".mysql_error($base));
//mysqli_select_db ('test', $base);
//$sql = 'select count(*) from membre where login="******" and
//pass_md5="'. $base->quote($_POST['pass']).'"';
//$requete= $base->query($sql) or die('Erreur sql !'.$sql.mysql_error());
 public function Logout(UserSession $user)
 {
     Log::Debug('Attempting CAS logout for email: %s', $user->Email);
     $this->authToDecorate->Logout($user);
     if ($this->options->CasHandlesLogouts()) {
         phpCAS::logoutWithRedirectService('http://' . $_SERVER['SERVER_NAME']);
     }
 }