Commit f825664f authored by Brett Bieber's avatar Brett Bieber
Browse files

Import whoami code from Thiltges, Liebgott, Bieber

parents
<?PHP
if ($_SERVER['REQUEST_METHOD'] != 'GET')
{
exit("Invalid request method");
}
include("../phpcas-devel/source/CAS.php");
if (isset($_REQUEST['id'])) {
// Set the age to 1 day to improve speed/caching.
header('Expires: ' . date('r', strtotime('now + 1 day')));
session_cache_limiter('private_no_expire');
session_cache_expire(24*60);
// Start session
session_start();
// Clear session on id change
if (isset($_SESSION['id']) and $_SESSION['id'] != $_REQUEST['id']) {
session_unset();
}
// Store id into session
$_SESSION['id'] = $_REQUEST['id'];
}
// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'login.unl.edu',443,'/cas');
// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();
// check CAS authentication
$auth = phpCAS::checkAuthentication();
header('Content-type: application/json');
print "WDN.idm.user = ";
if ($auth) {
// Get authenticated username
$username = phpCAS::getUser();
print file_get_contents("http://directory.unl.edu/service.php?format=json&uid=$username");
} else {
print "{}";
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment