"Fossies" - the Fresh Open Source Software Archive

Member "OCSNG_UNIX_SERVER_2.6/ocsreports/libraries/phpcas/docs/examples/example_simple.php" (17 Apr 2019, 1871 Bytes) of package /linux/privat/OCSNG_UNIX_SERVER_2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 /**
    4  *   Example for a simple cas 2.0 client
    5  *
    6  * PHP Version 5
    7  *
    8  * @file     example_simple.php
    9  * @category Authentication
   10  * @package  PhpCAS
   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
   15  */
   16 
   17 // Load the settings from the central config file
   18 require_once 'config.php';
   19 // Load the CAS lib
   20 require_once $phpcas_path . '/CAS.php';
   21 
   22 // Enable debugging
   23 phpCAS::setDebug();
   24 // Enable verbose error messages. Disable in production!
   25 phpCAS::setVerbose(true);
   26 
   27 // Initialize phpCAS
   28 phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);
   29 
   30 // For production use set the CA certificate that is the issuer of the cert
   31 // on the CAS server and uncomment the line below
   32 // phpCAS::setCasServerCACert($cas_server_ca_cert_path);
   33 
   34 // For quick testing you can disable SSL validation of the CAS server.
   35 // THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
   36 // VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
   37 phpCAS::setNoCasServerValidation();
   38 
   39 // force CAS authentication
   40 phpCAS::forceAuthentication();
   41 
   42 // at this step, the user has been authenticated by the CAS server
   43 // and the user's login name can be read with phpCAS::getUser().
   44 
   45 // logout if desired
   46 if (isset($_REQUEST['logout'])) {
   47     phpCAS::logout();
   48 }
   49 
   50 // for this test, simply print that the authentication was successfull
   51 ?>
   52 <html>
   53   <head>
   54     <title>phpCAS simple client</title>
   55   </head>
   56   <body>
   57     <h1>Successfull Authentication!</h1>
   58     <?php require 'script_info.php' ?>
   59     <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
   60     <p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
   61     <p><a href="?logout=">Logout</a></p>
   62   </body>
   63 </html>