1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <?php
//
// phpCAS simple client
//
// import phpCAS lib
include_once('CAS.php');
phpCAS::setDebug();
// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'localhost',8080,'');
// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}
if (isset($_REQUEST['login'])) {
phpCAS::forceAuthentication();
}
// check CAS authentication
$auth = phpCAS::checkAuthentication();
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<?php
if ($auth) {
// for this test, simply print that the authentication was successfull
?>
<h1>Successfull Authentication!</h1>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
<?php
} else {
?>
<h1>Guest mode</h1>
<p><a href="?login=">Login</a></p>
<?php
}
?>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
</body>
</html> |
Partager