本文整理汇总了PHP中phpCAS::checkAuthentication方法的典型用法代码示例。如果您正苦于以下问题:PHP phpCAS::checkAuthentication方法的具体用法?PHP phpCAS::checkAuthentication怎么用?PHP phpCAS::checkAuthentication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpCAS
的用法示例。
在下文中一共展示了phpCAS::checkAuthentication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Logs the user out / destroys the CAS session
*/
public function index()
{
if (\phpCAS::checkAuthentication()) {
\phpCAS::logout();
}
session_destroy();
header("Location: /landing");
return;
}
示例2: checkAuth
function checkAuth()
{
if (CASUser::setup()) {
//Allow it to be called multiple times, and return the auth info
//Normally it will force a login if this isn't done
return phpCAS::checkAuthentication();
} else {
return CASUser::isAuthenticated();
}
}
示例3: check_login
function check_login($callback)
{
if (isLoggedIn()) {
return true;
}
if ($callback->controller == 'users' && $callback->action == 'create') {
return true;
}
// if(phpCAS::isAuthenticated()) {
// login_login();
//}
if (phpCAS::checkAuthentication()) {
login_login();
}
}
示例4: 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();
session_start();
$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;
}
}
if (isset($_GET["userdebug"])) {
include_once "typo3conf/ext/dlcube_hn_01/class.WebservicesCompte.php";
include_once "typo3conf/ext/dlcube_hn_01/class.WebservicesAccess.php";
$param[] = array("login" => $_GET["userdebug"], "ctx" => null);
$ws = new WebservicesCompte();
if (!$ws->connectIdent()) {
$content = "ERROR:" . $ws->getErrorMessage();
return $content;
}
$result = $ws->getPersonneByLogin($param);
debug($result);
print_r($result);
}
if (isset($_GET["action"]) && $_GET["action"] == "auth" && !isset($_GET["ticket"])) {
phpCAS::setDebug();
phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
$ur = phpCAS::getServerLoginURL(false);
$content .= '<IFRAME src="' . $ur . '" frameborder="no" height="600" width="670"></IFRAME>';
return $this->pi_wrapInBaseClass($content);
}
phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
phpCAS::checkAuthentication();
$_SESSION["portalId"] = phpCAS::getUser();
echo '<html><body><script type="text/javascript">
window.open( "' . $this->pi_getPageLink($_SESSION["service_id_auth"]) . '", "_top");
</script></body>';
exit;
}
示例5: main
/**
* Cette methode permet de verifier si l'utilisateur
* du portail poss�de d�j� une authentification SSO sur le
* serveur CAS.
* Si ce dernier ne poss�de pas d'authetification, le plugin redirige l'utilisateur sur
* une page d'authentification CAS dans une iframe.
*/
function main($content, $conf)
{
session_start();
//$idPageAuth = '3434';
$idPageAuth = '3682';
$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;
}
}
//debug($_SESSION);
if ($GLOBALS["TSFE"]->page["tx_dlcube04CAS_auth_cas_required"] == 1) {
phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true');
$auth = phpCAS::checkAuthentication();
if (!$auth) {
$_SESSION["service_id_auth"] = $GLOBALS["TSFE"]->id;
header('Location: ' . t3lib_div::locationHeaderUrl($this->pi_getPageLink($idPageAuth, "", array("action" => "auth"))));
exit;
} else {
$_SESSION["portalId"] = phpCAS::getUser();
}
}
if (isset($_GET["action_cas"]) && $_GET["action_cas"] == "logout") {
unset($_SESSION["portalId"]);
header('Location: ' . t3lib_div::locationHeaderUrl($this->pi_getPageLink("3683", "", array("action" => "disconnect"))));
}
/**
* Gestion des langues pour le cookie
*/
if (isset($_GET["lang"])) {
if ($_GET["lang"] == "fr") {
$this->cookie_fr();
}
if ($_GET["lang"] == "en") {
$this->cookie_en();
}
}
}
示例6: actionLogin
/**
* Displays the login page
*/
public function actionLogin()
{
Yii::import('application.vendors.CAS.*');
include_once 'CAS/Autoload.php';
spl_autoload_unregister(array('YiiBase', 'autoload'));
spl_autoload_register(array('YiiBase', 'autoload'));
include_once 'CAS.php';
phpCAS::setDebug();
phpCAS::client(CAS_VERSION_2_0, 'sso.ui.ac.id', 443, 'cas');
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
phpCAS::checkAuthentication();
$username = phpCAS::getUser();
$identity = new UserIdentity($username);
if ($identity->authenticate()) {
Yii::app()->user->login($identity);
}
$this->redirect(array('home/index'));
}
示例7: loginpage_hook
/**
* authentication choice (CAS or other)
* redirection to the CAS form or to login/index.php
* for other authentication
*/
function loginpage_hook()
{
global $frm;
global $CFG;
global $SESSION;
$site = get_site();
$CASform = get_string("CASform", "auth");
$username = optional_param("username");
if (!empty($username)) {
if (strstr($SESSION->wantsurl, 'ticket') || strstr($SESSION->wantsurl, 'NOCAS')) {
unset($SESSION->wantsurl);
}
return;
}
// Test si cas activ� et param�tres non remplis
if (empty($this->config->hostname)) {
return;
}
// Connection to CAS server
$this->connectCAS();
// Gestion de la connection CAS si acc�s direct d'un ent ou autre
if (phpCAS::checkAuthentication()) {
$frm->username = phpCAS::getUser();
// if (phpCAS::getUser()=='esup9992')
// $frm->username='erhar0062';
$frm->password = "passwdCas";
return;
}
if ($_GET["loginguest"] == true) {
$frm->username = "guest";
$frm->password = "guest";
return;
}
if ($this->config->multiauth) {
$authCAS = optional_param("authCAS");
if ($authCAS == "NOCAS") {
return;
}
// choice authentication form for multi-authentication
// test pgtIou parameter for proxy mode (https connection
// in background from CAS server to the php server)
if ($authCAS != "CAS" && !isset($_GET["pgtIou"])) {
$navlinks = array();
$navlinks[] = array('name' => $CASform, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("{$site->fullname}: {$CASform}", $site->fullname, $navigation);
include $CFG->dirroot . "/auth/cas/cas_form.html";
print_footer();
exit;
}
}
// CAS authentication
if (!phpCAS::isAuthenticated()) {
phpCAS::forceAuthentication();
}
}
示例8: send_to_cas
function send_to_cas($config)
{
require_once dirname(__DIR__) . '/vendor/autoload.php';
try {
// get module configuration
$cas_version = $config->cas_version ? $config->cas_version : CAS_VERSION_2_0;
// phpCAS::setDebug();
phpCAS::client($cas_version, $config->cashostname, (int) $config->casport, $config->casbaseuri, false);
// check authentication; returns true/false
$result = phpCAS::checkAuthentication();
if ($result) {
// grab username
$NetUsername = phpCAS::getUser();
return $NetUsername;
} else {
return false;
}
} catch (Exception $e) {
error_log("CAS ERROR: " . $e->getMessage());
register_error($e->getMessage());
return false;
}
}
示例9: RWSPCReqs
function RWSPCReqs()
{
global $RWSESL3;
global $RWSCRURL;
$r_rwc = RWSGSOpt("rwscas", PARAM_ALPHANUM);
if ($r_rwc === false || strlen($r_rwc) == 0) {
return;
}
if ($r_rwc != "1" && $r_rwc != "2" && $r_rwc != "3") {
return;
}
$r_ver = RWSGSOpt("version", PARAM_ALPHANUMEXT);
if ($r_ver === false || strlen($r_ver) == 0) {
return;
}
$r_rwu = RWSGSOpt("rwsuser", PARAM_RAW);
if ($r_rwu === false || strlen($r_rwu) == 0) {
unset($r_rwu);
}
$r_rwp = RWSGSOpt("rwspass", PARAM_RAW);
if ($r_rwp === false || strlen($r_rwp) == 0) {
unset($r_rwp);
}
$r_tkt = RWSGSOpt("ticket", PARAM_RAW);
if ($r_tkt === false || strlen($r_tkt) == 0) {
unset($r_tkt);
}
$r_pid = RWSGSOpt("pgtId", PARAM_RAW);
if ($r_pid === false || strlen($r_pid) == 0) {
unset($r_pid);
}
$r_piou = RWSGSOpt("pgtIou", PARAM_RAW);
if ($r_piou === false || strlen($r_piou) == 0) {
unset($r_piou);
}
$r_aus = get_enabled_auth_plugins();
foreach ($r_aus as $r_aun) {
$r_aup = get_auth_plugin($r_aun);
if (strcasecmp($r_aup->authtype, RWSCAS) == 0) {
$r_csp = $r_aup;
break;
}
}
if (!isset($r_csp)) {
return;
}
if (empty($r_csp->config->hostname)) {
return;
}
list($r_v1, $r_v2, $r_v3) = explode(".", phpCAS::getVersion());
$r_csp->connectCAS();
if ($r_rwc == "1") {
if (isset($r_tkt)) {
RWSRHXml();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
echo "<rwscas>\r\n";
echo "\t<st>";
echo utf8_encode(htmlspecialchars(trim($r_tkt)));
echo "\t</st>\r\n";
echo "</rwscas>\r\n";
exit;
} else {
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$r_ok = phpCAS::checkAuthentication();
if (!isset($r_rwu)) {
$r_rwu = phpCAS::getUser();
}
if (!isset($r_rwp)) {
$r_rwp = "passwdCas";
}
RWSLIMUser($r_rwu, $r_rwp, $r_ok);
} else {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$r_psd = urldecode(file_get_contents("php://input"));
if (stripos($r_psd, "<samlp:LogoutRequest ") !== false) {
RWSAOLog();
}
}
}
}
} else {
if ($r_rwc == "2") {
if (isset($r_pid) && isset($r_piou)) {
if ($r_csp->config->proxycas) {
phpCAS::checkAuthentication();
}
} else {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$r_psd = urldecode(file_get_contents("php://input"));
if (stripos($r_psd, "<samlp:LogoutRequest ") !== false) {
RWSAOLog();
}
}
}
} else {
if ($r_rwc == "3") {
if (isset($r_tkt)) {
if (strlen($RWSCRURL) > 0) {
$r_svu = $RWSCRURL;
} else {
//.........这里部分代码省略.........
示例10: get_path
}
// Render
$claroline->display->body->setContent($template->render());
if (!(isset($_REQUEST['logout']) && isset($_SESSION['isVirtualUser']))) {
echo $claroline->display->render();
}
} else {
require_once get_path('clarolineRepositorySys') . '/desktop/index.php';
}
// Logout request : delete session data
if (isset($_REQUEST['logout'])) {
if (isset($_SESSION['isVirtualUser'])) {
unset($_SESSION['isVirtualUser']);
claro_redirect(get_conf('rootWeb') . 'claroline/admin/admin_users.php');
exit;
}
// notify that a user has just loggued out
if (isset($logout_uid)) {
$eventNotifier->notifyEvent('user_logout', array('uid' => $logout_uid));
}
/* needed to be able to :
- log with claroline when 'magic login' has previously been clicked
- notify logout event
(logout from CAS has been commented in casProcess.inc.php)*/
if (get_conf('claro_CasEnabled', false) && (get_conf('claro_CasGlobalLogout') && !phpCAS::checkAuthentication())) {
phpCAS::logout((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . get_conf('urlAppend') . '/index.php');
}
session_destroy();
}
// Hide breadcrumbs and view mode on platform home page
// $claroline->display->banner->hideBreadcrumbLine();
示例11: authenticate
/**
* Authenticates the user with CAS and fulfills setting changes (login/out and gender change).
* $force: whether or not to require login
* $controller: required to access the model and check what page is being visited
*/
private function authenticate($force, $controller)
{
// Load the settings from the central config file
require_once __DIR__ . '/../config/cas-config.php';
// Load the CAS lib
require_once $phpcas_path . '/CAS.php';
// Enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
// Set the CA certificate that is the issuer of the cert on the CAS server
phpCAS::setCasServerCACert($cas_server_ca_cert_path);
// log in or out if desired
if (isset($_REQUEST['login'])) {
phpCAS::forceAuthentication();
}
if (isset($_REQUEST['logout'])) {
if (!isset($_SESSION)) {
if (!isset($_SESSION)) {
session_start();
}
}
session_destroy();
phpCAS::logout(array('service' => URL, 'url' => URL));
}
if ($force) {
phpCAS::forceAuthentication();
} else {
phpCAS::checkAuthentication();
}
// Raise an exception if the user has insufficient privileges for an admin page.
if (in_array(strtolower(get_class($controller)), $this->admin_controllers) && (!Helper::isLoggedIn() || !$controller->model->userIsAdmin(phpCAS::getUser()))) {
// Sorry about using runtime, but I don't really want to subclass anything :/
throw new RuntimeException("Must log in as admin.");
}
if (Helper::isLoggedIn()) {
if (isset($_REQUEST['male'])) {
$gender = 'male';
} elseif (isset($_REQUEST['female'])) {
$gender = 'female';
} elseif (isset($_REQUEST['all'])) {
$gender = 'both';
}
if (isset($gender)) {
$controller->model->setGender($gender, phpCAS::getUser());
}
}
}
示例12: header
<?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="'. $base->quote($_POST['login']).'" and
//pass_md5="'. $base->quote($_POST['pass']).'"';
//$requete= $base->query($sql) or die('Erreur sql !'.$sql.mysql_error());
示例13: status
/**
* Check login status of current user with regards to Purdue CAS
*
* @return array $status
*/
public function status()
{
$status = array();
if (Config::Get('debug')) {
$debug_location = $this->params->get('debug_location', '/var/log/apache2/php/phpCAS.log');
phpCAS::setDebug($debug_location);
}
$this->initialize();
if (phpCAS::checkAuthentication()) {
$status['username'] = phpCAS::getUser();
}
return $status;
}
示例14: loginpage_hook
/**
* Authentication choice (CAS or other)
* Redirection to the CAS form or to login/index.php
* for other authentication
*/
function loginpage_hook()
{
global $frm;
global $CFG;
global $SESSION, $OUTPUT, $PAGE;
$site = get_site();
$CASform = get_string('CASform', 'auth_cas');
$username = optional_param('username', '', PARAM_RAW);
$courseid = optional_param('courseid', 0, PARAM_INT);
if (!empty($username)) {
if (isset($SESSION->wantsurl) && (strstr($SESSION->wantsurl, 'ticket') || strstr($SESSION->wantsurl, 'NOCAS'))) {
unset($SESSION->wantsurl);
}
return;
}
// Return if CAS enabled and settings not specified yet
if (empty($this->config->hostname)) {
return;
}
// If the multi-authentication setting is used, check for the param before connecting to CAS.
if ($this->config->multiauth) {
// If there is an authentication error, stay on the default authentication page.
if (!empty($SESSION->loginerrormsg)) {
return;
}
$authCAS = optional_param('authCAS', '', PARAM_RAW);
if ($authCAS == 'NOCAS') {
return;
}
// Show authentication form for multi-authentication.
// Test pgtIou parameter for proxy mode (https connection in background from CAS server to the php server).
if ($authCAS != 'CAS' && !isset($_GET['pgtIou'])) {
$PAGE->set_url('/login/index.php');
$PAGE->navbar->add($CASform);
$PAGE->set_title("{$site->fullname}: {$CASform}");
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
include $CFG->dirroot . '/auth/cas/cas_form.html';
echo $OUTPUT->footer();
exit;
}
}
// Connection to CAS server
$this->connectCAS();
if (phpCAS::checkAuthentication()) {
$frm = new stdClass();
$frm->username = phpCAS::getUser();
$frm->password = 'passwdCas';
// Redirect to a course if multi-auth is activated, authCAS is set to CAS and the courseid is specified.
if ($this->config->multiauth && !empty($courseid)) {
redirect(new moodle_url('/course/view.php', array('id' => $courseid)));
}
return;
}
if (isset($_GET['loginguest']) && $_GET['loginguest'] == true) {
$frm = new stdClass();
$frm->username = 'guest';
$frm->password = 'guest';
return;
}
// Force CAS authentication (if needed).
if (!phpCAS::isAuthenticated()) {
phpCAS::setLang($this->config->language);
phpCAS::forceAuthentication();
}
}
示例15: validate_user_cas
function validate_user_cas(&$user, $checkOnly = false)
{
global $tikilib, $prefs, $base_url;
// just make sure we're supposed to be here
if (!$this->_init_cas_client()) {
return false;
}
// Redirect to this URL after authentication
if ( !empty($prefs['cas_extra_param']) && basename($_SERVER['SCRIPT_NAME']) == 'tiki-login.php' ) {
phpCAS::setFixedServiceURL($base_url . 'tiki-login.php?cas=y&' . $prefs['cas_extra_param']);
}
// check CAS authentication
phpCAS::setNoCasServerValidation();
if ( $checkOnly ) {
unset($_SESSION['phpCAS']['auth_checked']);
$auth = phpCAS::checkAuthentication();
} else {
$auth = phpCAS::forceAuthentication();
}
$_SESSION['cas_validation_time'] = $tikilib->now;
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
if ( $auth && ($user = strtolower(phpCAS::getUser())) ) {
return USER_VALID;
} else {
$user = null;
return PASSWORD_INCORRECT;
}
}