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

logout now works in cas_auth_unl; pulling in the same login form in both the...

logout now works in cas_auth_unl; pulling in the same login form in both the colorbox and pg/login now
parent 515d68f1
No related branches found
No related tags found
No related merge requests found
......@@ -83,3 +83,9 @@ elgg/featured/ http://its-gforge.unl.edu/svn/unl_huskers/trunk/
All patches are located in the /pathces directory. These include:
/pathces/lowercase_post.diff
*******
** Things to look out for when new versions of Elgg are released
*******
-- Are there changes to /elgg/actions/login.php and /elgg/actions/logout.php ?????
We have overridden those actions with our own in the cas_auth_unl plugin
\ No newline at end of file
......@@ -38,9 +38,16 @@
$token = generate_action_token($ts);
SimpleCAS::setURL('http://ucommrasmussen.unl.edu/workspace/UNL_Elgg/elgg/action/login?usecas=yes&__elgg_ts='.$ts.'&__elgg_token='.$token);
$casObject->forceCas();
} else {
$cas_user = $casObject->getUserCas();
if ($user = $casObject->casAuthenticate($cas_user)) {
$result = login($user);
if ($result)
$_SESSION['loggedInWithCas'] = true;
}
}
$casObject->poopoo();
}
// Set the system_message as appropriate
......
<?php
/**
* Elgg logout action for use with UNL CAS
*
* @package Elgg
* @subpackage Core
* @overwritten cas_auth_unl/actions/logout.php
* @author Curverider Ltd
* @link http://elgg.org/
*/
// Save this session value since the next step wipes it out
$loggedInWithCas = $_SESSION['loggedInWithCas'];
// Log out
$result = logout();
// Set the system_message as appropriate
if ($result) {
system_message(elgg_echo('logoutok'));
} else {
register_error(elgg_echo('logouterror'));
}
// We've destoyed all the Elgg session data, now do CAS logout if neccessary
// Due to problems getting the SimpleCAS logout to work, we're just forwarding to the right URL since
// the Elgg logout function above took care of destroying the session, which is all the SimpleCAS logout
// was doing anyway.
if ($loggedInWithCas) {
global $CONFIG;
forward('https://login.unl.edu/cas/logout?url='.$CONFIG->url);
}
?>
\ No newline at end of file
......@@ -17,45 +17,18 @@
function cas_auth_unl_init() {
global $CONFIG;
if ($_GET['loginwith'] == 'UNLlogin') {
if (checkCas()) {
$_SESSION['loggedWithCAS'] = true;
$cas_user = getUserCas();
if (casAuthenticate($cas_user)) {
system_message(elgg_echo('loginok'));
$cas_user = str_replace('-','_',$cas_user);
//user is logged in now, this is the last step - forward based on whether they have logged in before
if (!$_SESSION['user']->last_login)
forward('mod/profile/edit.php?firstlogin=yes');
else
forward("pg/profile/unl_" . $cas_user);
} else {
register_error(elgg_echo('loginerror'));
}
} else {
forceCas();
}
}
}
//*************->Start
register_action("getemail",true,$CONFIG->pluginspath . "cas_auth_unl/views/default/actions/getemail.php");
register_action("login",false,$CONFIG->pluginspath. "cas_auth_unl/actions/login.php");
register_action("logout",false,$CONFIG->pluginspath. "cas_auth_unl/actions/logout.php");
// Fire up the plugin initialization using the elgg handler
register_elgg_event_handler('init','system','cas_auth_unl_init');
// Register CAS logout to main logout only if user logged with CAS
if (isset($_SESSION['loggedWithCAS']) && $_SESSION['loggedWithCAS']==true) {
// register_elgg_event_handler('logout', 'user', 'logoutCas');
}
// Set up login page, this creates the url /pg/login to be used as our login page
register_page_handler('login', 'login_page_handler');
......@@ -82,57 +55,51 @@ class elggSimpleCas {
function __construct() {
if (!$this->casInitialized) {
// Elgg blows away $_GET at some point which SimpleCAS tries to use so we will reset it
if ($ticket = get_input('ticket')) {
$_GET['ticket'] = $ticket;
}
// Setup CAS
$config = find_plugin_settings('cas_auth_unl');
$options = array('hostname' => $config->casurl,
'port' => $config->casport,
'uri' => $config->casuri);
$protocol = new SimpleCAS_Protocol_Version2($options);
$request = $protocol->getRequest();
// SSL doesn't work right on login.unl.edu
$defaultClass = SimpleCAS_Protocol::DEFAULT_REQUEST_CLASS;
if ($request instanceof $defaultClass) {
$protocol->getRequest()->setConfig('ssl_verify_peer', false);
}
// Create Our Client
$this->client = SimpleCAS::client($protocol);
$this->casInitialized = true;
}
return true;
}
function poopoo(){
header('Location: http://google.com');exit();
}
function forceCas() {
public function forceCas() {
$this->client->forceAuthentication();
return true;
}
function checkCas() {
if ($this->client->isAuthenticated()) {
public function checkCas() {
if ($this->client->isAuthenticated())
return true;
}
else
return false;
}
public function getUserCas() {
return $this->client->getUsername();
}
function logoutCas() {
global $CONFIG;
phpCAS::logout($CONFIG->url.'/action/logout');
public function logoutCas() {
$this->client->logout();
return true;
}
/**
* Perform the CAS Authentication
*
* @param string $username
* @return boolean
*/
function casAuthenticate($username){
public function casAuthenticate($username){
if (empty($username))
return false;
......@@ -150,8 +117,8 @@ class elggSimpleCas {
$username = str_replace('-','_',$username);
if ($user = get_user_by_username($username)) {
// User exists, login
return login($user);
// User exists, return the user object
return $user;
} else {
// Valid login but user doesn't exist
$pf_user_info = peoplefinderServices($casusername);
......@@ -168,7 +135,7 @@ class elggSimpleCas {
}
try {
if ($user_guid = register_user($username, 'generic', $name, $email, false, 0, '', true)) {
if ($user_guid = register_user($username, generate_random_cleartext_password(), $name, $email, false, 0, '', true)) {
$thisuser = get_user($user_guid);
//pre-populate profile fields with data from Peoplefinder Services
......@@ -184,16 +151,14 @@ class elggSimpleCas {
$thisuser->latitude = 40.82;
}
return login($thisuser);
return $thisuser;
} else {
register_error(elgg_echo("registerbad"));
}
} catch (RegistrationException $r) {
register_error($r->getMessage());
}
}
}
......
......@@ -11,7 +11,8 @@
global $CONFIG;
?>
<?php /*
<div id="login">
<div class="two_col left">
<h2 class="sec_main">Students, Faculty, Staff</h2>
......@@ -23,7 +24,7 @@
$form_body .= elgg_view('input/submit', array('value' => elgg_echo('UNL Login'))) . '</p>';
$ts = time();
$token = generate_action_token($ts);
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login?usecas=yes&__elgg_ts='.$ts.'&__elgg_token='.$token"));
?>
<p style="margin-top: 40px;"><a title="Find your my.UNL password" href="https://login.unl.edu/faq/account-resetpw.shtml">Lost your my.UNL password?</a></p>
......@@ -38,4 +39,28 @@
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
?>
</div>
</div>
*/ ?>
<div id="login">
<div class="two_col left">
<h2 class="sec_main">Students, Faculty, Staff</h2>
<p>Use your my.UNL Single Sign-on account to begin.</p>
<?php
$ts = time();
$token = generate_action_token($ts);
?>
<a href="<?php echo $CONFIG->url ?>action/login?usecas=yes&__elgg_ts=<?php echo $ts; ?>&__elgg_token=<?php echo $token; ?>" class="wdn_loginLink"><span>UNL Login</span></a>
<p style="margin-top:85px"><a href="https://login.unl.edu/faq/account-resetpw.shtml" title="Find your my.UNL password">Lost your my.UNL password?</a></p>
</div>
<div class="two_col right">
<h2 class="sec_main">Huskers Worldwide</h2>
<?php
$form_body = "<p class=\"login-box\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
$form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
?>
</div>
</div>
\ No newline at end of file
<div id="login">
<div class="two_col right">
<h2 class="sec_main">Huskers Worldwide</h2>
<?php
$form_body = "<p class=\"login-box\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
$form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
?>
</div>
</div>
\ No newline at end of file
......@@ -32,27 +32,11 @@
</div>
</div>
</div>
<?php //This is the login details hidden with CSS and displayed in the colorbox.?>
<?php //This is the login details hidden with CSS and displayed in the colorbox. With CAS enabled this comes from cas_auth_unl views folder?>
<div class="hidden">
<div id="login">
<div class="two_col left">
<h2 class="sec_main">Students, Faculty, Staff</h2>
<p>Use your my.UNL Single Sign-on account to begin.</p>
<a href="<?php echo $CONFIG->url ?>?loginwith=UNLlogin" class="wdn_loginLink"><span>UNL Login</span></a>
<p style="margin-top:85px"><a href="https://login.unl.edu/faq/account-resetpw.shtml" title="Find your my.UNL password">Lost your my.UNL password?</a></p>
</div>
<div class="two_col right">
<h2 class="sec_main">Huskers Worldwide</h2>
<?php
$form_body = "<p class=\"login-box\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
$form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
$form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";
echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
?>
</div>
</div>
<?php echo elgg_view('account/forms/login'); ?>
</div>
<?php }?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment