• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • Examples
  • File List
  • File Members

docs/examples/example_gateway.php

Go to the documentation of this file.
00001 <?php
00002 // Example that uses the CAS gateway feature
00003 
00004 // Load the settings from the central config file
00005 include_once('config.php');
00006 // Load the CAS lib
00007 include_once($phpcas_path.'/CAS.php');
00008 
00009 // Uncomment to enable debugging
00010 phpCAS::setDebug();
00011 
00012 // Initialize phpCAS
00013 phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
00014 
00015 // For production use set the CA certificate that is the issuer of the cert 
00016 // on the CAS server and uncomment the line below
00017 // phpCAS::setCasServerCACert($cas_server_ca_cert_path);
00018 
00019 // For quick testing you can disable SSL validation of the CAS server. 
00020 // THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION. 
00021 // VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL! 
00022 phpCAS::setNoCasServerValidation();
00023 
00024 if (isset($_REQUEST['logout'])) {
00025   phpCAS::logout();
00026 }
00027 if (isset($_REQUEST['login'])) {
00028   phpCAS::forceAuthentication();
00029 }
00030 
00031 // check CAS authentication
00032 $auth = phpCAS::checkAuthentication();
00033 
00034 ?>
00035 <html>
00036   <head>
00037     <title>phpCAS simple client</title>
00038   </head>
00039   <body>
00040 <?php
00041 if ($auth) {
00042   // for this test, simply print that the authentication was successfull
00043 ?>
00044     <h1>Successfull Authentication!</h1>
00045     <?php include 'script_info.php' ?>
00046     <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
00047     <p><a href="?logout=">Logout</a></p>
00048 <?php
00049 } else {
00050 ?>
00051     <h1>Guest mode</h1>
00052     <p><a href="?login=">Login</a></p>
00053 <?php
00054 }
00055 ?>
00056     <p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
00057   </body>
00058 </html>

Generated on Sun Jun 5 2011 19:05:26 for phpCAS by  doxygen 1.7.1