本文整理汇总了PHP中phpCAS::client方法的典型用法代码示例。如果您正苦于以下问题:PHP phpCAS::client方法的具体用法?PHP phpCAS::client怎么用?PHP phpCAS::client使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpCAS
的用法示例。
在下文中一共展示了phpCAS::client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// These are default values for the first login and should be changed via GUI
$CAS_HOSTNAME = 'your.domain.org';
$CAS_PORT = '443';
$CAS_PATH = '/cas';
$this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
$this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
$this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
$this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
$this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
$this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
$this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
$casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
$casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $CAS_HOSTNAME);
$casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', $CAS_PORT);
$casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', $CAS_PATH);
$casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
global $initialized_cas;
if (!$initialized_cas) {
phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
if (!empty($casCertPath)) {
phpCAS::setCasServerCACert($casCertPath);
} else {
phpCAS::setNoCasServerValidation();
}
$initialized_cas = true;
}
}
示例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;
}
示例3: init_cas_client
private function init_cas_client()
{
if (class_exists('phpCAS')) {
return true;
}
require getConfig('casldap_phpcas_path');
$cas_debug_file = getConfig('cas_debug_file_path');
if (!empty($cas_debug_file)) {
phpCAS::setDebug($cas_debug_file);
}
$cas_host = getConfig('cas_host');
$cas_port = getConfig('cas_port') or 443;
$cas_context = getConfig('cas_context');
switch (getConfig('cas_version')) {
case 1:
$cas_version = CAS_VERSION_1_0;
break;
case 2:
$cas_version = CAS_VERSION_2_0;
break;
case 3:
$cas_version = CAS_VERSION_3_0;
break;
default:
$cas_version = CAS_VERSION_2_0;
break;
}
phpCAS::client($cas_version, $cas_host, intval($cas_port), $cas_context);
$cas_server_ca_cert_path = getConfig('cas_server_ca_cert_path');
if ($cas_server_ca_cert_path) {
phpCAS::setCasServerCACert($cas_server_ca_cert_path);
} else {
phpCAS::setNoCasServerValidation();
}
}
示例4: initialized_php_cas
public static function initialized_php_cas()
{
if (!self::$_initialized_php_cas) {
$casVersion = OCP\Config::getAppValue('user_cas', 'cas_server_version', '2.0');
$casHostname = OCP\Config::getAppValue('user_cas', 'cas_server_hostname', $_SERVER['SERVER_NAME']);
$casPort = OCP\Config::getAppValue('user_cas', 'cas_server_port', 443);
$casPath = OCP\Config::getAppValue('user_cas', 'cas_server_path', '/cas');
$casDebugFile = OCP\Config::getAppValue('user_cas', 'cas_debug_file', '');
$casCertPath = OCP\Config::getAppValue('user_cas', 'cas_cert_path', '');
$php_cas_path = OCP\Config::getAppValue('user_cas', 'cas_php_cas_path', 'CAS.php');
if (!class_exists('phpCAS')) {
if (empty($php_cas_path)) {
$php_cas_path = 'CAS.php';
}
OC_Log::write('cas', "Try to load phpCAS library ({$php_cas_path})", OC_Log::DEBUG);
include_once $php_cas_path;
if (!class_exists('phpCAS')) {
OC_Log::write('cas', 'Fail to load phpCAS library !', OC_Log::ERROR);
return false;
}
}
if ($casDebugFile !== '') {
phpCAS::setDebug($casDebugFile);
}
phpCAS::client($casVersion, $casHostname, (int) $casPort, $casPath, false);
if (!empty($casCertPath)) {
phpCAS::setCasServerCACert($casCertPath);
} else {
phpCAS::setNoCasServerValidation();
}
self::$_initialized_php_cas = true;
}
return self::$_initialized_php_cas;
}
示例5: 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);
}
示例6: init
/**
* Initialize the class, this must be called before anything else
* @param $config
* @param bool $changeSessionID Allow phpCAS to change the session_id (Single Sign Out/handleLogoutRequests is based on that change)
* @param $debugLog Set to a path to enable debug log
*/
public static function init($config, $changeSessionID = true, $debugLog = null)
{
if ($debugLog != null) {
phpCAS::setDebug($debugLog);
}
phpCAS::client(CAS_VERSION_2_0, $config['site'], $config['port'], "cas", $changeSessionID);
self::$config = $config;
$private_key = null;
if (isset($config['private_key'])) {
$key = static::resolve_filename($config['private_key']);
$private_key = openssl_get_privatekey("file:///{$key}");
if ($private_key === false) {
throw new NXAuthError("Failed to open private key {$key}");
}
}
if (isset($config['ca_cert']) && $config['ca_cert'] != null) {
self::$ca_cert = static::resolve_filename($config['ca_cert']);
phpCAS::setCasServerCACert(self::$ca_cert);
} else {
phpCAS::setNoCasServerValidation();
// Disable curl ssl verification
phpCAS::setExtraCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
phpCAS::setExtraCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
}
NXAPI::init(array('private_key' => $private_key, 'key_id' => $config['key_id'], 'url' => "https://" . $config['site'], 'ca_cert' => self::$ca_cert));
}
示例7: 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));
}
示例8: 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;
}
示例9: 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/');
}
}
}
示例10: main
/**
* [Put your description here]
*/
function main($content, $conf)
{
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_USER_INT_obj = 1;
// Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
$this->pi_loadLL();
$this->typeExecution = "prod";
$urlCas = "none";
$portCas = "none";
if ($this->typeExecution == "dev") {
$urlCas = "xinf-devlinux.intranet.haras-nationaux.fr";
$portCas = 7777;
} else {
if ($this->typeExecution == "prod") {
$urlCas = "cerbere.haras-nationaux.fr";
$portCas = 443;
}
}
session_start();
if (isset($_GET["action"]) && $_GET["action"] == "disconnect") {
phpCAS::setDebug();
phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
$ur = phpCAS::getServerLogoutURL();
phpCAS::killSession();
//Suppression de la sesssion de harasire
setcookie("netid", "", time() - 3600, "/", ".haras-nationaux.fr");
//$urCid = "http://www4.haras-nationaux.fr/cid-internet-web/InvalidateSessionServlet?service=".$ur;
$content .= '<IFRAME src="' . $ur . '" frameborder="no" height="600" width="670"></IFRAME>';
return $this->pi_wrapInBaseClass($content);
}
}
示例11: __construct
public function __construct()
{
\phpCAS::setDebug();
\phpCAS::client(CAS_VERSION_2_0, "itebeta.baidu.com", 443, "");
\phpCAS::setNoCasServerValidation();
\phpCAS::forceAuthentication();
$this->username = \phpCAS::getUser();
}
示例12: __construct
public function __construct()
{
$setup = self::loadSetup();
$this->client = phpCAS::client(CAS_VERSION_2_0, $setup['host'], $setup['port'], $setup['context']);
// For simplicities sake at the moment we are not validating the server auth.
phpCAS::setNoCasServerValidation();
phpCAS::setPostAuthenticateCallback(array($this, 'loginCallback'));
}
示例13: init
public function init($options)
{
parent::init($options);
$this->cas_server = $this->getOption("CAS_SERVER");
$this->cas_port = $this->getOption("CAS_PORT");
$this->cas_uri = $this->getOption("CAS_URI");
phpCAS::client(CAS_VERSION_1_0, $this->cas_server, $this->cas_port, $this->cas_uri, false);
phpCAS::setNoCasServerValidation();
}
示例14: prepare
private function prepare()
{
\phpCAS::client(CAS_VERSION_2_0, $this->casUrl, $this->casPort, $this->casUri, false);
//\phpCAS::setDebug('/tmp/cas.log');
\phpCAS::setNoCasServerValidation();
//\phpCAS::setSingleSignoutCallback(array($this, 'casSingleSignOut'));
//\phpCAS::setPostAuthenticateCallback(array($this, 'casPostAuth'));
\phpCAS::handleLogoutRequests(true, $this->casAllowedIpClients);
}
示例15: initPhpCAS
function initPhpCAS($host, $port, $context, $CA_certificate_file)
{
phpCAS::client(SAML_VERSION_1_1, $host, intval($port), $context, false);
if ($CA_certificate_file) {
phpCAS::setCasServerCACert($CA_certificate_file);
} else {
phpCAS::setNoCasServerValidation();
}
//phpCAS::setLang(PHPCAS_LANG_FRENCH);
}