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

docs/examples/example_advanced_saml11.php

Go to the documentation of this file.
00001 <?php
00002 // Advanced example for SAML with attributes and single logout
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(SAML_VERSION_1_1, $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 // Handle SAML logout requests that emanate from the CAS host exclusively.
00025 // Failure to restrict SAML logout requests to authorized hosts could
00026 // allow denial of service attacks where at the least the server is
00027 // tied up parsing bogus XML messages.
00028 phpCAS::handleLogoutRequests(true, $cas_real_hosts);
00029 
00030 // Force CAS authentication on any page that includes this file
00031 phpCAS::forceAuthentication();
00032 
00033 ?>
00034 <h2>Secure Page</h2>
00035 <?php include 'script_info.php' ?>
00036 
00037 Authentication succeeded for user
00038 <strong><?php echo phpCAS::getUser(); ?></strong>.
00039 
00040 <h3>User Attributes</h3>
00041 <ul>
00042 <?php
00043 foreach (phpCAS::getAttributes() as $key => $value) {
00044 if (is_array($value)) {
00045 echo '<li>', $key, ':<ol>';
00046 foreach($value as $item) {
00047       echo '<li><strong>', $item, '</strong></li>';
00048     }
00049 echo '</ol></li>';
00050 } else {
00051     echo '<li>', $key, ': <strong>', $value, '</strong></li>';
00052   }
00053 }
00054 ?>
00055 </ul>

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