Skip to content
Snippets Groups Projects
Commit 8c04741c authored by Tim Steiner's avatar Tim Steiner
Browse files

Set the correct logout url for the CAS logout link.

Emulate single sign out using the unl_sso cookie.
Force a CAS check at least once an hour.


git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x@79 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 8b4cb9c9
Branches
Tags
No related merge requests found
......@@ -5,16 +5,20 @@ function unl_cas_init()
require_once dirname(__FILE__) . '/lib/CAS/CAS.php';
phpCAS::client(CAS_VERSION_2_0,'login.unl.edu',443,'/cas');
phpCAS::setNoCasServerValidation();
phpCAS::handleLogoutRequests();
if (!array_key_exists('last_sso_check', $_SESSION)) {
$_SESSION['unl']['last_sso_check'] = 0;
// Force a real CAS attempt every hour or whenever the unl_sso cookie disappears.
if ($_SESSION['unl']['last_sso_check'] < time() - 60*60 ||
!array_key_exists('unl_sso', $_COOKIE) && phpCAS::isSessionAuthenticated())
{
unset($_SESSION['phpCAS']['user']);
$_SESSION['unl']['last_sso_check'] = time();
}
$auth = FALSE;
if (array_key_exists('unl_sso', $_COOKIE)) {
$auth = phpCAS::checkAuthentication();
}
if ($auth) {
$username = phpCAS::getUser();
$user = user_load_by_name($username);
......@@ -65,3 +69,14 @@ function unl_cas_import_user($username)
$user = user_save(NULL, $userData);
return $user;
}
function unl_cas_page_alter(&$page)
{
$logoutUrl = url('user/logout');
$ssoScript = <<<EOF
<script type="text/javascript">
WDN.idm.setLogoutURL('$logoutUrl');
</script>
EOF;
$page['page_bottom']['sso']['#markup'] = $ssoScript;
}
......@@ -5,6 +5,8 @@ core = 7.x
engine = phptemplate
stylesheets[all][] = style.css
regions[content] = Main Content
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[navlinks] = Navigation Links
regions[leftcollinks] = Related Links
regions[contactinfo] = Contact Us
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment