File: cas.php

package info (click to toggle)
lemonldap-ng 2.22.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 28,516 kB
  • sloc: perl: 82,515; javascript: 25,474; xml: 6,473; makefile: 1,327; sh: 492; sql: 159; python: 55; php: 26
file content (49 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

require_once("/usr/share/php/CAS.php");
phpCAS::setDebug();
$host = $_SERVER{'SERVER_NAME'};
$host_components = explode( ".", $host);
$cas_host = "auth.".$host_components[1].".".$host_components[2];
$cas_port = 443;
$cas_context = "/cas";

phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);

phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();

if (isset($_REQUEST['logout'])) {
    phpCAS::logout();
}

?>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>CAS PHP test</title>
</head>
<body>
<h1>CAS PHP test</h1>
<p>The user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<h3>User Attributes</h3>
<ul>
<?php
foreach (phpCAS::getAttributes() as $key => $value) {
    if (is_array($value)) {
        echo '<li>', $key, ':<ol>';
        foreach ($value as $item) {
            echo '<li><strong>', $item, '</strong></li>';
        }
        echo '</ol></li>';
    } else {
        echo '<li>', $key, ': <strong>', $value, '</strong></li>' . PHP_EOL;
    }
}
    ?>
</ul>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>