phpCAS  version 1.4.0
example_advanced_saml11.php
Go to the documentation of this file.
1 <?php
2 
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
24 // Enable verbose error messages. Disable in production!
25 phpCAS::setVerbose(true);
26 
27 // Initialize phpCAS
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
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 // Handle SAML logout requests that emanate from the CAS host exclusively.
40 // Failure to restrict SAML logout requests to authorized hosts could
41 // allow denial of service attacks where at the least the server is
42 // tied up parsing bogus XML messages.
44 
45 // Force CAS authentication on any page that includes this file
47 
48 // Some small code triggered by the logout button
49 if (isset($_REQUEST['logout'])) {
51 }
52 ?>
53 <html>
54  <head>
55  <title>Advanced SAML 1.1 example</title>
56  </head>
57  <body>
58 <h2>Advanced SAML 1.1 example</h2>
59 <?php require 'script_info.php' ?>
60 
61 Authentication succeeded for user
62 <strong><?php echo phpCAS::getUser(); ?></strong>.
63 
64 <h3>User Attributes</h3>
65 <ul>
66 <?php
67 foreach (phpCAS::getAttributes() as $key => $value) {
68  if (is_array($value)) {
69  echo '<li>', $key, ':<ol>';
70  foreach ($value as $item) {
71  echo '<li><strong>', $item, '</strong></li>';
72  }
73  echo '</ol></li>';
74  } else {
75  echo '<li>', $key, ': <strong>', $value, '</strong></li>' . PHP_EOL;
76  }
77 }
78  ?>
79 </ul>
80 <p><a href="?logout=">Logout</a></p>
81 </body>
82 </html>
static forceAuthentication()
Definition: CAS.php:1146
static getUser()
Definition: CAS.php:1227
const SAML_VERSION_1_1
Definition: CAS.php:91
static handleLogoutRequests($check_client=true, $allowed_clients=array())
Definition: CAS.php:1324
$cas_server_ca_cert_path
$cas_real_hosts
static getAttributes()
Definition: CAS.php:1246
static client($server_version, $server_hostname, $server_port, $server_uri, $changeSessionID=true, \SessionHandlerInterface $sessionHandler=null)
Definition: CAS.php:345
$phpcas_path
static setLogger($logger=null)
Definition: CAS.php:448
static logout($params="")
Definition: CAS.php:1480
static setCasServerCACert($cert, $validate_cn=true)
Definition: CAS.php:1670
static setVerbose($verbose)
Definition: CAS.php:512
$cas_host
$cas_context
$cas_port