Skip to content
Snippets Groups Projects
Commit 541fdd53 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Merge branch 'fix_wdn_v6' into 'master'

Changed different endpoint to url param

See merge request !2
parents 3f719839 f5277a07
No related branches found
No related tags found
1 merge request!2Changed different endpoint to url param
<?php
if ($_SERVER['REQUEST_METHOD'] != 'GET') {
exit("Invalid request method");
}
// multiple server neccessities in the CMS environment
$_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
// session_save_path($_SERVER['DOCUMENT_ROOT'] . '/../unl.edu/tmp');
ini_set("session.save_handler", "memcached");
ini_set("session.save_path", "10.172.23.62:11211, 10.172.25.145:11211");
include(__DIR__ . "../phpCAS/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, 'shib.unl.edu', 443, '/idp/profile/cas');
// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();
if (!phpCAS::isAuthenticated()) {
//Remove cache headers to prevent IE from caching an empty redirect (during gateway auth)
header_remove('Expires');
header_remove('Cache-Control');
}
// check CAS authentication
$auth = phpCAS::checkAuthentication();
header('Content-type: application/json');
if ($auth) {
// Get authenticated username
$username = phpCAS::getUser();
print file_get_contents("https://directory.unl.edu/service.php?format=json&uid=$username");
} else {
print "{}";
}
...@@ -46,8 +46,14 @@ if (!phpCAS::isAuthenticated()) { ...@@ -46,8 +46,14 @@ if (!phpCAS::isAuthenticated()) {
// check CAS authentication // check CAS authentication
$auth = phpCAS::checkAuthentication(); $auth = phpCAS::checkAuthentication();
if (isset($_REQUEST['v']) && $_REQUEST['v'] === '6') {
header('Content-type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
} else {
header('Content-type: application/javascript'); header('Content-type: application/javascript');
print "WDN.idm.user = "; print "WDN.idm.user = ";
}
if ($auth) { if ($auth) {
// Get authenticated username // Get authenticated username
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment