phpCAS version 1.3.6

example_no_ssl_cn_validation.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
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 // You can also disable the validation of the certficate CN. This means the
39 // certificate must be valid but the CN of the certificate must not match the
40 // IP or hostname you are using to access the server
41 phpCAS::setCasServerCACert($cas_server_ca_cert_path, false);
42
43
44 // force CAS authentication
45 phpCAS::forceAuthentication();
46
47 // at this step, the user has been authenticated by the CAS server
48 // and the user's login name can be read with phpCAS::getUser().
49
50 // logout if desired
51 if (isset($_REQUEST['logout'])) {
52 phpCAS::logout();
53 }
54
55 // for this test, simply print that the authentication was successfull
56 ?>
57 <html>
58 <head>
59 <title>phpCAS simple client</title>
60 </head>
61 <body>
62 <h1>Successfull Authentication!</h1>
63 <?php require 'script_info.php' ?>
64 <p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
65 <p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
66 <p><a href="?logout=">Logout</a></p>
67 </body>
68 </html>
phpCAS\forceAuthentication
static forceAuthentication()
Definition: CAS.php:1094
phpCAS
Definition: CAS.php:278
$cas_server_ca_cert_path
$cas_server_ca_cert_path
Definition: config.example.php:36
$phpcas_path
$phpcas_path
Definition: config.example.php:20
CAS_VERSION_2_0
const CAS_VERSION_2_0
Definition: CAS.php:78
phpCAS\logout
static logout($params="")
Definition: CAS.php:1430
phpCAS\setCasServerCACert
static setCasServerCACert($cert, $validate_cn=true)
Definition: CAS.php:1620
phpCAS\setVerbose
static setVerbose($verbose)
Definition: CAS.php:481
$cas_host
$cas_host
Definition: config.example.php:27
$cas_context
$cas_context
Definition: config.example.php:30
phpCAS\setDebug
static setDebug($filename='')
Definition: CAS.php:439
$cas_port
$cas_port
Definition: config.example.php:33
phpCAS\client
static client($server_version, $server_hostname, $server_port, $server_uri, $changeSessionID=true)
Definition: CAS.php:338