当前位置: 首页>>代码示例>>PHP>>正文


PHP phpCAS::forceAuthentication方法代码示例

本文整理汇总了PHP中phpCAS::forceAuthentication方法的典型用法代码示例。如果您正苦于以下问题:PHP phpCAS::forceAuthentication方法的具体用法?PHP phpCAS::forceAuthentication怎么用?PHP phpCAS::forceAuthentication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpCAS的用法示例。


在下文中一共展示了phpCAS::forceAuthentication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkAndSetUserSession

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/');
        }
    }
}
开发者ID:guuurris,项目名称:skolprojektOchLabbar,代码行数:26,代码来源:index.php

示例2: get_login

 public function get_login()
 {
     Logger::debug('main', 'AuthMethod_CAS::get_login()');
     if (!isset($_SESSION['backup_sso']) || !is_array($_SESSION['backup_sso'])) {
         $_SESSION['backup_sso'] = array();
     }
     foreach ($_REQUEST as $k => $v) {
         $_SESSION['backup_sso'][$k] = $v;
     }
     $buf = $this->prefs->get('AuthMethod', 'CAS');
     $CAS_server_url = $buf['user_authenticate_cas_server_url'];
     if (!isset($CAS_server_url) || $CAS_server_url == '') {
         Logger::error('main', 'AuthMethod_CAS::get_login() - Unable to find CAS server url in Preferences');
         return NULL;
     }
     phpCAS::client(CAS_VERSION_2_0, parse_url($CAS_server_url, PHP_URL_HOST), parse_url($CAS_server_url, PHP_URL_PORT), parse_url($CAS_server_url, PHP_URL_PATH));
     Logger::debug('main', 'AuthMethod_CAS::get_login() - Parsing URL - Host:"' . parse_url($CAS_server_url, PHP_URL_HOST) . '" Port:"' . parse_url($CAS_server_url, PHP_URL_PORT) . '" Path:"' . parse_url($CAS_server_url, PHP_URL_PATH) . '"');
     phpCAS::setNoCasServerValidation();
     if (!phpCAS::forceAuthentication()) {
         Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::forceAuthentication failed');
         return NULL;
     }
     if (!phpCAS::isAuthenticated()) {
         Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::isAuthenticated failed');
         return NULL;
     }
     $this->login = phpCAS::getUser();
     foreach ($_SESSION['backup_sso'] as $k => $v) {
         if (isset($_REQUEST[$k])) {
             continue;
         }
         $_REQUEST[$k] = $v;
     }
     return $this->login;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:35,代码来源:CAS.php

示例3: execute

 public function execute($filterChain)
 {
     $user = $this->getContext()->getUser();
     // We put an LDAP object in the context in order to reuse it later
     $this->getContext()->set('ldap', new uapvLdap());
     // Filters can be called several times (because of internal forwards)
     // Authentication is only done the first time
     if ($this->isFirstCall() && (sfConfig::get('app_cas_server_force_authentication', false) || !$user->isAuthenticated())) {
         // phpCAS is not php5-compliant, we remove php warnings and strict errors
         $errorReporting = ini_get('error_reporting');
         error_reporting($errorReporting & ~E_STRICT & ~E_NOTICE);
         if (sfConfig::get('app_cas_server_debug', false)) {
             phpCAS::setDebug();
         }
         // see /tmp/phpCAS.log
         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
         //phpCAS::handleLogoutRequests ();
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         // if necessary the user will be
         // redirected to the cas server
         // At this point the user is authenticated, we log him in
         $user->signIn(phpCAS::getUser());
         // Previous settings can now be restored
         error_reporting($errorReporting);
     }
     // "credential" verification
     parent::execute($filterChain);
 }
开发者ID:ArnaudD,项目名称:RdvZ,代码行数:31,代码来源:uapvSecurityFilterCas.class.php

示例4: forceAuth

function forceAuth()
{
    if (!phpCAS::isAuthenticated()) {
        // If they're not currently logged in, take them to the RPI CAS page
        phpCAS::forceAuthentication();
    }
}
开发者ID:justetz,项目名称:SlateCrate,代码行数:7,代码来源:functions.php

示例5: force_login

function force_login()
{
    if (!isset($GLOBALS['PHPCAS_CLIENT'])) {
        check_auth();
    }
    phpCAS::forceAuthentication();
}
开发者ID:niclush2009,项目名称:DBLS,代码行数:7,代码来源:core_functions.php

示例6: metodillo

 function metodillo()
 {
     $sSQL = "SELECT * FROM PM_PARAMETERS WHERE PRM_ID = 'CAS_URL' ";
     $aResSQL = executeQuery($sSQL);
     if (count($aResSQL)) {
         $sURL = $aResSQL[1]['PRM_VALUE'];
         $sURI = $aResSQL[1]['PRM_VALUE_2'];
         $res = false;
         $RBAC = RBAC::getSingleton();
         $RBAC->initRBAC();
         require_once 'CAS-1.2.2/CAS.php';
         phpCAS::client(CAS_VERSION_2_0, $sURL, 443, $sURI, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         if (phpCAS::isAuthenticated() == true) {
             $sCasUser = phpCAS::getUser();
             $sSQL = "SELECT USR_UID FROM USERS WHERE USR_USERNAME = '{$sCasUser}' ";
             $aResSQL = executeQuery($sSQL);
             if (count($aResSQL)) {
                 $nUserId = $aResSQL[1]['USR_UID'];
                 $RBAC->singleSignOn = true;
                 $RBAC->userObj->fields['USR_UID'] = $nUserId;
                 $RBAC->userObj->fields['USR_USERNAME'] = $sCasUser;
                 $res = true;
             } else {
                 $res = false;
             }
         } else {
             $res = false;
         }
     } else {
         $res = false;
     }
     return $res;
 }
开发者ID:juantroche,项目名称:pmos-cas,代码行数:35,代码来源:class.cas2.php

示例7: beforeLogin

 public function beforeLogin()
 {
     // configure phpCAS
     $cas_host = $this->get('casAuthServer');
     $cas_context = $this->get('casAuthUri');
     $cas_port = (int) $this->get('casAuthPort');
     // import phpCAS lib
     $basedir = dirname(__FILE__);
     Yii::setPathOfAlias('myplugin', $basedir);
     Yii::import('myplugin.third_party.CAS.*');
     require_once 'third_party/CAS/CAS.php';
     // Initialize phpCAS
     phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context, false);
     // disable SSL validation of the CAS server
     phpCAS::setNoCasServerValidation();
     //force CAS authentication
     phpCAS::forceAuthentication();
     $this->setUsername(phpCAS::getUser());
     $oUser = $this->api->getUserByName($this->getUserName());
     if ($oUser || $this->get('autoCreate')) {
         // User authenticated and found. Cas become the authentication system
         $this->getEvent()->set('default', get_class($this));
         $this->setAuthPlugin();
         // This plugin handles authentication, halt further execution of auth plugins
     } elseif ($this->get('is_default', null, null)) {
         // Fall back to another authentication mecanism
         throw new CHttpException(401, 'Wrong credentials for LimeSurvey administration.');
     }
 }
开发者ID:withhope,项目名称:HIT-Survey,代码行数:29,代码来源:AuthCAS.php

示例8: index

 /**
  * Attempts to authenticate users via CAS
  */
 public function index()
 {
     // If they don't have CAS configured, send them onto the application's
     // internal authentication system
     if (!defined('CAS')) {
         header('Location: ' . BASE_URL . '/login/login?return_url=' . $this->return_url);
         exit;
     }
     require_once CAS . '/CAS.php';
     \phpCAS::client(CAS_VERSION_2_0, CAS_SERVER, 443, CAS_URI, false);
     \phpCAS::setNoCasServerValidation();
     \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().
     // They may be authenticated according to CAS,
     // but that doesn't mean they have person record
     // and even if they have a person record, they may not
     // have a user account for that person record.
     try {
         $_SESSION['USER'] = new Person(\phpCAS::getUser());
         header("Location: {$this->return_url}");
         exit;
     } catch (\Exception $e) {
         $_SESSION['errorMessages'][] = $e;
     }
     $this->template->blocks[] = new Block('loginForm.inc', array('return_url' => $this->return_url));
 }
开发者ID:CodeForEindhoven,项目名称:uReport,代码行数:30,代码来源:LoginController.php

示例9: beforeLogin

 public function beforeLogin()
 {
     if (!is_null($this->api->getRequest()->getParam('noAuthCAS')) || $this->api->getRequest()->getIsPostRequest()) {
         # Local authentication forced through 'noAuthCAS' url parameter
         $this->getEvent()->set('default', "Authdb");
     } else {
         // configure phpCAS
         $cas_host = $this->get('casAuthServer');
         $cas_context = $this->get('casAuthUri');
         $cas_port = (int) $this->get('casAuthPort');
         $cas_version = $this->get('casVersion');
         // import phpCAS lib
         $basedir = dirname(__FILE__);
         Yii::setPathOfAlias('myplugin', $basedir);
         Yii::import('myplugin.third_party.CAS.CAS', true);
         // Initialize phpCAS
         phpCAS::client($cas_version, $cas_host, $cas_port, $cas_context, false);
         // disable SSL validation of the CAS server
         phpCAS::setNoCasServerValidation();
         //force CAS authentication
         phpCAS::forceAuthentication();
         $this->setUsername(phpCAS::getUser());
         $oUser = $this->api->getUserByName($this->getUserName());
         if ($oUser || (int) $this->get('autoCreate') > 0) {
             // User authenticated and found. Cas become the authentication system
             $this->getEvent()->set('default', get_class($this));
             $this->setAuthPlugin();
             // This plugin handles authentication, halt further execution of auth plugins
         } elseif ($this->get('is_default', null, null)) {
             // Fall back to another authentication mecanism
             throw new CHttpException(401, 'Wrong credentials for LimeSurvey administration.');
         }
     }
 }
开发者ID:johnny-y-wang,项目名称:limesurvey-cas,代码行数:34,代码来源:AuthCAS.php

示例10: startup

 /** 
  * Main execution method.  Initializes CAS client and force authentication if required before passing user to parent startup method.
  * 
  * @param object $controller A reference to the instantiating controller object 
  * @return boolean 
  * @access public 
  */
 function startup(&$controller)
 {
     // CAS authentication required if user is not logged in
     //debug($controller);exit;
     //if (!$this->user()) {
     if (!isset($this->request->query['ticket'])) {
         // Set debug mode
         phpCAS::setDebug(false);
         //if(!empty(phpCAS::getUser()))
         //    debug($this);
         //Initialize phpCAS
         //debug(isset($this->request->query['ticket']));
         phpCAS::client(CAS_VERSION_2_0, Configure::read('CAS.hostname'), Configure::read('CAS.port'), Configure::read('CAS.uri'));
         // No SSL validation for the CAS server
         phpCAS::setNoCasServerValidation();
         // Force CAS authentication if required
         phpCAS::forceAuthentication();
         //debug();exit;
         $model =& $this->getModel();
         $controller->data[$model->alias][$this->fields['username']] = phpCAS::getUser();
         $controller->data[$model->alias][$this->fields['password']] = 'a';
         //$this->User->['username']=phpCAS::getUser();
         //$this->User->['password']='a';
     }
     return parent::startup($controller);
     //$this->redirect(array('controller'=>'User','action'=>'login'));
 }
开发者ID:rajankz,项目名称:webspace,代码行数:34,代码来源:CasAuthComponent+copy.php

示例11: forceAuth

 function forceAuth()
 {
     if (!CASUser::isAuthenticated()) {
         phpCAS::forceAuthentication();
         return false;
     }
     return true;
 }
开发者ID:andrewroth,项目名称:ccc_connexion_bar_php,代码行数:8,代码来源:CASUser.php

示例12: checkAuthentication

 public function checkAuthentication()
 {
     if (phpCAS::isAuthenticated() && !AuthCookie::hasAuthCookie()) {
         $this->loginCallback();
     }
     // force CAS authentication
     phpCAS::forceAuthentication();
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:8,代码来源:class.cas_auth_backend.php

示例13: __construct

 public function __construct()
 {
     \phpCAS::setDebug();
     \phpCAS::client(CAS_VERSION_2_0, "itebeta.baidu.com", 443, "");
     \phpCAS::setNoCasServerValidation();
     \phpCAS::forceAuthentication();
     $this->username = \phpCAS::getUser();
 }
开发者ID:sayi21cn,项目名称:Atomu,代码行数:8,代码来源:Uuap.class.php

示例14: checkAuthentication

 public function checkAuthentication()
 {
     if (phpCAS::isAuthenticated() && !Auth::isValidCookie(Auth::getCookieInfo(APP_COOKIE))) {
         $this->loginCallback();
     }
     // force CAS authentication
     $auth = phpCAS::forceAuthentication();
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:8,代码来源:class.cas_auth_backend.php

示例15: login

 public static function login()
 {
     if (self::$_user) {
         return self::$_user;
     }
     self::init();
     phpCAS::forceAuthentication();
     session_write_close();
     return phpCAS::getUser();
 }
开发者ID:JohnnyChenS,项目名称:mock-server,代码行数:10,代码来源:Phpcas.php


注:本文中的phpCAS::forceAuthentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。