phpCAS
version 1.4.0
docs
examples
example_pgt_storage_db.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::setLogger
();
24
// Enable verbose error messages. Disable in production!
25
phpCAS::setVerbose
(
true
);
26
27
// Initialize phpCAS
28
phpCAS::proxy
(
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
// set PGT storage to file in plain format in the same directory as session files
40
phpCAS::setPGTStorageDB(
$db
,
$db_user
,
$db_password
,
$db_table
);
41
42
// force CAS authentication
43
phpCAS::forceAuthentication
();
44
45
// at this step, the user has been authenticated by the CAS server
46
// and the user's login name can be read with phpCAS::getUser().
47
48
// moreover, a PGT was retrieved from the CAS server that will
49
// permit to gain accesses to new services.
50
51
?>
52
<html>
53
<head>
54
<title>
phpCAS
proxy example with PGT storage to a database</title>
55
<link rel=
"stylesheet"
type=
'text/css'
href=
'example.css'
/>
56
</head>
57
<body>
58
<h1>
phpCAS
proxy example with PGT storage to file</h1>
59
<?php require
'script_info.php'
?>
60
<p>the user
's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
61
<h2>Response from service <?php echo $serviceUrl; ?></h2>
62
<?php
63
flush();
64
// call a service and change the color depending on the result
65
if (phpCAS::serviceWeb($serviceUrl, $err_code, $output)) {
66
echo '
<div
class
=
"success"
>
';
67
} else {
68
echo '
<div
class
=
"error"
>
';
69
}
70
echo $output;
71
echo '
</div>
';
72
?>
73
</body>
74
</html>
phpCAS\forceAuthentication
static forceAuthentication()
Definition:
CAS.php:1146
phpCAS
Definition:
CAS.php:281
phpCAS\proxy
static proxy($server_version, $server_hostname, $server_port, $server_uri, $changeSessionID=true, \SessionHandlerInterface $sessionHandler=null)
Definition:
CAS.php:391
$db_table
$db_table
Definition:
config.example.php:58
$phpcas_path
$phpcas_path
Definition:
config.example.php:20
$db
$db
Definition:
config.example.php:54
phpCAS\setLogger
static setLogger($logger=null)
Definition:
CAS.php:448
CAS_VERSION_2_0
const CAS_VERSION_2_0
Definition:
CAS.php:78
$db_password
$db_password
Definition:
config.example.php:57
$db_user
$db_user
Definition:
config.example.php:56
phpCAS\setVerbose
static setVerbose($verbose)
Definition:
CAS.php:512
$cas_host
$cas_host
Definition:
config.example.php:27
$cas_context
$cas_context
Definition:
config.example.php:30
$cas_port
$cas_port
Definition:
config.example.php:33
phpCAS\setNoCasServerValidation
static setNoCasServerValidation()
Definition:
CAS.php:1689
Generated by
1.8.13