<?php
/**
* Example for a simple cas 2.0 client
* Taken from the official CAS example
* PHP 5.4.0, CAS 1.3.0
*/
// Load the CAS lib
require_once 'CAS.php';
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, 'www.itsmetor.com', 443, '/cas');
// For quick testing you can disable SSL validation of the CAS server.
phpCAS::setNoCasServerValidation();
// force CAS authentication
// If CAS determines you are not authenticated, they will redirect you to their site and
// prompt for credentials
//
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().
// logout if desired, check for this before we print anything
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}
// for this test, simply print that the authentication was successfull
echo "The user's login is: " . phpCAS::getUser();
echo "phpCAS version is: " . phpCAS::getVersion();
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<p>The user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>
/**
* Example for a simple cas 2.0 client
* Taken from the official CAS example
* PHP 5.4.0, CAS 1.3.0
*/
// Load the CAS lib
require_once 'CAS.php';
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, 'www.itsmetor.com', 443, '/cas');
// For quick testing you can disable SSL validation of the CAS server.
phpCAS::setNoCasServerValidation();
// force CAS authentication
// If CAS determines you are not authenticated, they will redirect you to their site and
// prompt for credentials
//
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().
// logout if desired, check for this before we print anything
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}
// for this test, simply print that the authentication was successfull
echo "The user's login is: " . phpCAS::getUser();
echo "phpCAS version is: " . phpCAS::getVersion();
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<p>The user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>