4 * Example that changes the storage of the pgt tickets to file
8 * @file example_pgt_storage_db.php
9 * @category Authentication
11 * @author Joachim Fritschi <jfritschi@freenet.de>
12 * @author Adam Franco <afranco@middlebury.edu>
13 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
14 * @link https://wiki.jasig.org/display/CASC/phpCAS
17 // Load the settings from the central config file
18 require_once 'config.php';
20 require_once $phpcas_path . '/CAS.php';
22 // Uncomment to enable debugging
26 phpCAS::proxy(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
28 // For production use set the CA certificate that is the issuer of the cert
29 // on the CAS server and uncomment the line below
30 // phpCAS::setCasServerCACert($cas_server_ca_cert_path);
32 // For quick testing you can disable SSL validation of the CAS server.
33 // THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
34 // VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
35 phpCAS::setNoCasServerValidation();
37 // set PGT storage to file in plain format in the same directory as session files
38 phpCAS::setPGTStorageFile(session_save_path());
40 // force CAS authentication
41 phpCAS::forceAuthentication();
43 // at this step, the user has been authenticated by the CAS server
44 // and the user's login name can be read with phpCAS::getUser().
46 // moreover, a PGT was retrieved from the CAS server that will
47 // permit to gain accesses to new services.
52 <title>phpCAS proxy example with PGT storage to file</title>
53 <link rel="stylesheet" type='text/css' href='example.css'/>
56 <h1>phpCAS proxy example with PGT storage to file</h1>
57 <?php require 'script_info.php' ?>
58 <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
59 <h2>Response from service <?php echo $serviceUrl; ?></h2>
62 // call a service and change the color depending on the result
63 if ( phpCAS::serviceWeb($serviceUrl, $err_code, $output) ) {
64 echo '<div class="success">';
66 echo '<div class="error">';