Commit 732da48c authored by Leigh B. Stoller's avatar Leigh B. Stoller

Another crack at fixing ticket #213

parent d4510041
......@@ -56,7 +56,6 @@ class EmulabAuthModule(auth.LoginModule):
if not req.remote_user:
req.redirect(self.env.abs_href())
return
auth.LoginModule._do_login(self, req)
if req.args.get('goto'):
req.redirect(self.env.abs_href() + "/" + req.args.get('goto'))
else:
......@@ -94,17 +93,21 @@ class EmulabAuthModule(auth.LoginModule):
# tell the user agent to drop it as it is invalid.
return None
# Now delete it. Use-once token, and the underlying auth module
# will insert new auth info and generate a cookie.
if self.check_ip:
cursor.execute("DELETE FROM auth_cookie "
"WHERE cookie=%s AND name=%s AND ipnr=%s",
(hash, user, req.remote_addr))
else:
cursor.execute("DELETE FROM auth_cookie "
"WHERE cookie=%s and name=%s",
(hash, user))
db.commit()
shortname = os.path.basename(self.env.path)
#
# This is awful!
#
if shortname == "protogeni":
cookie_key = "trac_auth_" + str(self.cookie_suffix)
req.outcookie[cookie_key] = hash
req.outcookie[cookie_key]['path'] = req.href()
req.outcookie[cookie_key]['domain'] = ".protogeni.net";
pass
req.authname = user
return user
def _redirect_back(self, req):
......
......@@ -30,7 +30,7 @@ if (!isset($login)) {
$login = 0;
}
if ($wiki == "geni") {
if ($wiki == "geni" || $wiki == "protogeni") {
$geniproject = Project::Lookup("geni");
$approved = 0;
if (! ($geniproject &&
......@@ -53,7 +53,7 @@ else {
# Look for our cookie. If the browser has it, then there is nothing
# more to do; just redirect the user over to the wiki.
#
if (!$login && isset($_COOKIE[$TRACCOOKIENAME])) {
if (!$login && isset($_COOKIE[$COOKIENAME])) {
$url = $TRACURL;
if (isset($do)) {
$url .= "/" . $do;
......@@ -73,12 +73,7 @@ if (!preg_match("/^(\w*)$/", $suexec_output, $matches)) {
}
$hash = $matches[1];
if ($wiki == "protogeni") {
# We do this for the private wiki. Temporary.
setcookie($COOKIENAME, $hash, 0, "/", $TBAUTHDOMAIN, $TBSECURECOOKIES);
}
# This cookie tells boss that we have logged into Trac, but nothing else.
setcookie($TRACCOOKIENAME, $hash, 0, "/", $TBAUTHDOMAIN, $TBSECURECOOKIES);
setcookie($COOKIENAME, $hash, 0, "/", $TBAUTHDOMAIN, $TBSECURECOOKIES);
header("Location: ${TRACURL}/xlogin?user=$uid&hash=$hash" .
(isset($do) ? "&goto=${do}" : ""));
......
......@@ -994,7 +994,6 @@ function DOLOGIN_MAGIC($uid, $uid_idx, $email = null, $adminon = 0)
$TBAUTHDOMAIN, $TBSECURECOOKIES);
setcookie("trac_auth_protogeni_priv", "", $flushtime, "/",
$TBAUTHDOMAIN, $TBSECURECOOKIES);
setcookie($TRACCOOKIENAME, "", $flushtime, "/", $TBAUTHDOMAIN, 0);
}
DBQueryFatal("update users set ".
......@@ -1093,7 +1092,12 @@ function DOLOGOUT($user) {
setcookie($TBLOGINCOOKIE, "", $timeout, "/", $TBAUTHDOMAIN, 0);
if ($TRACSUPPORT) {
setcookie($TRACCOOKIENAME, "", $timeout, "/", $TBAUTHDOMAIN, 0);
setcookie("trac_auth_emulab", "", $timeout, "/",
$TBAUTHDOMAIN, 0);
setcookie("trac_auth_protogeni", "", $timeout, "/",
$TBAUTHDOMAIN, 0);
setcookie("trac_auth_protogeni_priv", "", $timeout, "/",
$TBAUTHDOMAIN, 0);
}
if ($WIKISUPPORT) {
setcookie($WIKICOOKIENAME, "", $timeout, "/", $TBAUTHDOMAIN, 0);
......
Markdown is supported
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