Commit 90dcbbe2 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Okay, I think I am finally done with WikiWhacking (or WhackingTheWiki?)

for the near future. Two big changes:

* Add WikiOnly accounts. An external user can register for an account on
  the wiki. Rather then use the registration stuff that comes with TWiki,
  redirect to new Emulab web page so we can manage all of the wiki accounts
  from one place. I modified the joinproject page to spit out a subset of
  the required fields so that its simple to get a wiki only account (just a
  few things to fill in).

  In keeping with current security practices, we still generate a
  verification email message to ensure the email address works. However,
  when the user completes the verification, the wiki account is created right
  away, rather then waiting for someone to approve it (since that would
  defeat the entire point of the wiki).

  Aside: I have not thought much about the conversion from a wiki-only
  account to a real account. That is going to happen, and it would be nice
  if that step did not require one of use to go in and hack the DB. Will
  cross that moat later.

  Aside: Rather beat up on the modify user info page too much, I continue
  to spit out the same form, but mark most of the fields as not required,
  and allow wiki-only people to not specify them.

* Both the joinproject and newproject pages sport a new WikiName field so
  that users can select their own WikiName. I added some JavaScript to
  both pages that generate a suitable wikiname from the FullName field, so
  that as soon as the user clicks out of the FullName, a default wikiname is
  inserted in the field.

  Both pages verify the wikinames by checking to make sure it is not
  already in use, and that it meets the WikiRules for WikiTopic names.
  (someone please shoot me if I continue to use WikiNotation).
parent 1b22ebcc
...@@ -58,6 +58,7 @@ ifeq ($(EVENTSYS),1) ...@@ -58,6 +58,7 @@ ifeq ($(EVENTSYS),1)
endif endif
@$(MAKE) -C mote post-install @$(MAKE) -C mote post-install
@$(MAKE) -C tools post-install @$(MAKE) -C tools post-install
@$(MAKE) -C wiki post-install
# #
# For installation on the 'ops' or 'users' node (okay, plastic) # For installation on the 'ops' or 'users' node (okay, plastic)
......
...@@ -167,7 +167,8 @@ if (AuditStart(0)) { ...@@ -167,7 +167,8 @@ if (AuditStart(0)) {
# #
$query_result = $query_result =
DBQueryFatal("select u.usr_pswd,u.unix_uid,u.usr_name, ". DBQueryFatal("select u.usr_pswd,u.unix_uid,u.usr_name, ".
" u.usr_email,u.status,u.webonly,u.usr_shell,admin,u.usr_w_pswd ". " u.usr_email,u.status,u.webonly,u.usr_shell,admin, ".
" u.usr_w_pswd,u.wikionly ".
"from users as u ". "from users as u ".
"where u.uid='$user'"); "where u.uid='$user'");
...@@ -184,6 +185,7 @@ my $webonly = $row[5]; ...@@ -184,6 +185,7 @@ my $webonly = $row[5];
my $usr_shell = $row[6]; my $usr_shell = $row[6];
my $usr_admin = $row[7]; my $usr_admin = $row[7];
my $wpswd = $row[8]; my $wpswd = $row[8];
my $wikionly = $row[9];
# #
# Get the users earliest project membership to use as the default group # Get the users earliest project membership to use as the default group
...@@ -273,10 +275,20 @@ sub AddUser() ...@@ -273,10 +275,20 @@ sub AddUser()
# #
# Check status. Only active users get accounts built. # Check status. Only active users get accounts built.
# #
if ($webonly || $status ne USERSTATUS_ACTIVE) { if ($webonly || $wikionly || $status ne USERSTATUS_ACTIVE) {
if ($webonly) { if ($webonly) {
return 0; return 0;
} }
if ($wikionly) {
$EUID = $UID;
# And to the wiki if enabled.
system("$ADDWIKIUSER $user")
if ($WIKISUPPORT && !$batch);
$EUID = 0;
return 0;
}
fatal("$user is not active! Cannot build an account!"); fatal("$user is not active! Cannot build an account!");
} }
......
...@@ -5,7 +5,7 @@ area for your project (or group). If you are not familiar with the ...@@ -5,7 +5,7 @@ area for your project (or group). If you are not familiar with the
information on how to write and create TWiki pages. information on how to write and create TWiki pages.
* YourFirstWikiTopic (See TWiki.WikiTopic for a brief description) * YourFirstWikiTopic (See TWiki.WikiTopic for a brief description)
* *
__This project wiki can be accessed externally as:__ [[%SCRIPTURL%/view/%WEB%][%SCRIPTURL%/view/%WEB%]] __This project wiki can be accessed externally as:__ [[%SCRIPTURL%/view/%WEB%][%SCRIPTURL%/view/%WEB%]]
......
...@@ -200,6 +200,10 @@ function TBvalid_usrname($token) { ...@@ -200,6 +200,10 @@ function TBvalid_usrname($token) {
return TBcheck_dbslot($token, "users", "usr_name", return TBcheck_dbslot($token, "users", "usr_name",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR); TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
} }
function TBvalid_wikiname($token) {
return TBcheck_dbslot($token, "users", "wikiname",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
}
function TBvalid_email($token) { function TBvalid_email($token) {
return TBcheck_dbslot($token, "users", "usr_email", return TBcheck_dbslot($token, "users", "usr_email",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR); TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR);
......
...@@ -863,6 +863,21 @@ function TBCurrentUser($uid) ...@@ -863,6 +863,21 @@ function TBCurrentUser($uid)
return mysql_num_rows($query_result); return mysql_num_rows($query_result);
} }
#
# Confirm a current WikiName or not.
#
# usage TBCurrentWikiName($uid)
# returns 1 if a current wikiname.
# returns 0 if not a current wikiname
#
function TBCurrentWikiName($wikiname)
{
$query_result =
DBQueryFatal("SELECT usr_pswd FROM users WHERE wikiname='$wikiname'");
return mysql_num_rows($query_result);
}
# #
# Check to see if an email is being used twice. # Check to see if an email is being used twice.
# #
...@@ -1502,6 +1517,14 @@ function TBCvswebAllowed($uid) { ...@@ -1502,6 +1517,14 @@ function TBCvswebAllowed($uid) {
return mysql_num_rows($query_result); return mysql_num_rows($query_result);
} }
function TBWikiOnlyUser($uid) {
$query_result =
DBQueryFatal("select wikionly from users ".
"WHERE uid='$uid' and wikionly=1");
return mysql_num_rows($query_result);
}
# #
# Returns > 0 if a node has a serial console, 0 if it does not # Returns > 0 if a node has a serial console, 0 if it does not
# #
......
...@@ -22,7 +22,8 @@ $uid = GETLOGIN(); ...@@ -22,7 +22,8 @@ $uid = GETLOGIN();
if ($uid) { if ($uid) {
# Allow unapproved users to join multiple groups ... # Allow unapproved users to join multiple groups ...
# Must be verified though. # Must be verified though.
LOGGEDINORDIE($uid, CHECKLOGIN_UNAPPROVED|CHECKLOGIN_WEBONLY); LOGGEDINORDIE($uid, CHECKLOGIN_UNAPPROVED|
CHECKLOGIN_WEBONLY|CHECKLOGIN_WIKIONLY);
$joining_uid = $uid; $joining_uid = $uid;
$returning = 1; $returning = 1;
} }
...@@ -33,6 +34,10 @@ else { ...@@ -33,6 +34,10 @@ else {
$returning = 0; $returning = 0;
} }
if (!isset($forwikionly)) {
$forwikionly = 0;
}
$ACCOUNTWARNING = $ACCOUNTWARNING =
"Before continuing, please make sure your username " . "Before continuing, please make sure your username " .
"reflects your normal login name. ". "reflects your normal login name. ".
...@@ -50,15 +55,32 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -50,15 +55,32 @@ function SPITFORM($formfields, $returning, $errors)
{ {
global $TBDB_UIDLEN, $TBDB_PIDLEN, $TBDB_GIDLEN; global $TBDB_UIDLEN, $TBDB_PIDLEN, $TBDB_GIDLEN;
global $ACCOUNTWARNING, $EMAILWARNING; global $ACCOUNTWARNING, $EMAILWARNING;
global $WIKISUPPORT, $forwikionly, $WIKIURL;
PAGEHEADER("Apply for Project Membership");
if ($forwikionly)
PAGEHEADER("Wiki Registration");
else
PAGEHEADER("Apply for Project Membership");
if (! $returning) { if (! $returning) {
echo "<center><font size=+1> echo "<center>\n";
if ($forwikionly) {
echo "<font size=+2>Register for an Emulab Wiki account</font>
<br><br>\n";
}
echo "<font size=+1>
If you already have an Emulab account, If you already have an Emulab account,
<a href=login.php3?refer=1> <a href=login.php3?refer=1>
<font color=red>please log on first!</font></a> <font color=red>please log on first!</font></a>
</font></center><br>\n"; </font>\n";
if ($forwikionly) {
echo "<br>(You will already have a wiki account)\n";
}
echo "</center><br>\n";
}
elseif ($forwikionly) {
USERERROR("You already have a Wiki account!", 1);
} }
if ($errors) { if ($errors) {
...@@ -82,6 +104,34 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -82,6 +104,34 @@ function SPITFORM($formfields, $returning, $errors)
} }
echo "</table><br>\n"; echo "</table><br>\n";
} }
echo "<SCRIPT LANGUAGE=JavaScript>
function SetWikiName(theform)
{
var validchars = 'abcdefghijklmnopqrstuvwxyz0123456789';
var usrname = theform['formfields[usr_name]'].value;
var wikiname = '';
var docap = 1;
for (var i = 0; i < usrname.length; i++) {
var letter = usrname.charAt(i).toLowerCase();
if (validchars.indexOf(letter) == -1) {
if (letter == ' ') {
docap = 1;
}
continue;
}
else {
if (docap == 1) {
letter = usrname.charAt(i).toUpperCase()
docap = 0;
}
wikiname = wikiname + letter;
}
}
theform['formfields[wikiname]'].value = wikiname;
}
</SCRIPT>\n";
echo "<table align=center border=1> echo "<table align=center border=1>
<tr> <tr>
...@@ -90,8 +140,10 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -90,8 +140,10 @@ function SPITFORM($formfields, $returning, $errors)
</td> </td>
</tr>\n </tr>\n
<form enctype=multipart/form-data <form name=myform enctype=multipart/form-data
action=joinproject.php3 method=post>\n"; action=" . ($forwikionly ?
"wikiregister.php3" : "joinproject.php3") . " " .
"method=post>\n";
if (! $returning) { if (! $returning) {
# #
...@@ -117,49 +169,68 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -117,49 +169,68 @@ function SPITFORM($formfields, $returning, $errors)
<td class=left> <td class=left>
<input type=text <input type=text
name=\"formfields[usr_name]\" name=\"formfields[usr_name]\"
onchange=\"SetWikiName(myform);\"
value=\"" . $formfields[usr_name] . "\" value=\"" . $formfields[usr_name] . "\"
size=30> size=30>
</td> </td>
</tr>\n"; </tr>\n";
#
# Title/Position:
#
echo "<tr>
<td colspan=2>*Title/Position:</td>
<td class=left>
<input type=text
name=\"formfields[usr_title]\"
value=\"" . $formfields[usr_title] . "\"
size=30>
</td>
</tr>\n";
#
# Affiliation:
#
echo "<tr>
<td colspan=2>*Institutional<br>Affiliation:</td>
<td class=left>
<input type=text
name=\"formfields[usr_affil]\"
value=\"" . $formfields[usr_affil] . "\"
size=40>
</td>
</tr>\n";
# #
# User URL # WikiName
# #
echo "<tr> if ($WIKISUPPORT) {
<td colspan=2>Home Page URL:</td> echo "<tr>
<td class=left> <td colspan=2>*
<input type=text <a href=${WIKIURL}/TWiki/WikiName
name=\"formfields[usr_URL]\" target=_blank>WikiName</a>:<td class=left>
value=\"" . $formfields[usr_URL] . "\" <input type=text
size=45> name=\"formfields[wikiname]\"
</td> value=\"" . $formfields[wikiname] . "\"
</tr>\n"; size=30>
</td>
</tr>\n";
}
if (! $forwikionly) {
#
# Title/Position:
#
echo "<tr>
<td colspan=2>*Title/Position:</td>
<td class=left>
<input type=text
name=\"formfields[usr_title]\"
value=\"" . $formfields[usr_title] . "\"
size=30>
</td>
</tr>\n";
#
# Affiliation:
#
echo "<tr>
<td colspan=2>*Institutional<br>Affiliation:</td>
<td class=left>
<input type=text
name=\"formfields[usr_affil]\"
value=\"" . $formfields[usr_affil] . "\"
size=40>
</td>
</tr>\n";
#
# User URL
#
echo "<tr>
<td colspan=2>Home Page URL:</td>
<td class=left>
<input type=text
name=\"formfields[usr_URL]\"
value=\"" . $formfields[usr_URL] . "\"
size=45>
</td>
</tr>\n";
}
# #
# Email: # Email:
...@@ -175,82 +246,88 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -175,82 +246,88 @@ function SPITFORM($formfields, $returning, $errors)
</td> </td>
</tr>\n"; </tr>\n";
echo "<tr><td colspan=3>*Postal Address:<br /><center> if (! $forwikionly) {
<table> #
<tr><td>Line 1</td><td colspan=3> # Postal Address
<input type=text #
name=\"formfields[usr_addr]\" echo "<tr><td colspan=3>*Postal Address:<br /><center>
value=\"" . $formfields[usr_addr] . "\" <table>
size=45></td></tr> <tr><td>Line 1</td><td colspan=3>
<tr><td>Line 2</td><td colspan=3> <input type=text
<input type=text name=\"formfields[usr_addr]\"
name=\"formfields[usr_addr2]\" value=\"" . $formfields[usr_addr] . "\"
value=\"" . $formfields[usr_addr2] . "\" size=45></td></tr>
size=45></td></tr> <tr><td>Line 2</td><td colspan=3>
<tr><td>City</td><td> <input type=text
<input type=text name=\"formfields[usr_addr2]\"
name=\"formfields[usr_city]\" value=\"" . $formfields[usr_addr2] . "\"
value=\"" . $formfields[usr_city] . "\" size=45></td></tr>
size=25></td> <tr><td>City</td><td>
<td>State/Province</td><td> <input type=text
<input type=text name=\"formfields[usr_city]\"
name=\"formfields[usr_state]\" value=\"" . $formfields[usr_city] . "\"
value=\"" . $formfields[usr_state] . "\" size=25></td>
size=2></td></tr> <td>State/Province</td><td>
<tr><td>ZIP/Postal Code</td><td> <input type=text
<input type=text name=\"formfields[usr_state]\"
name=\"formfields[usr_zip]\" value=\"" . $formfields[usr_state] . "\"
value=\"" . $formfields[usr_zip] . "\" size=2></td></tr>
size=10></td> <tr><td>ZIP/Postal Code</td><td>
<td>Country</td><td> <input type=text
<input type=text name=\"formfields[usr_zip]\"
name=\"formfields[usr_country]\" value=\"" . $formfields[usr_zip] . "\"
value=\"" . $formfields[usr_country] . "\" size=10></td>
size=15></td></tr> <td>Country</td><td>
</table></center></td></tr>"; <input type=text
name=\"formfields[usr_country]\"
# value=\"" . $formfields[usr_country] . "\"
# Phone size=15></td></tr>
# </table></center></td></tr>";
echo "<tr>
<td colspan=2>*Phone #:</td> #
<td class=left> # Phone
<input type=text #
name=\"formfields[usr_phone]\" echo "<tr>
value=\"" . $formfields[usr_phone] . "\" <td colspan=2>*Phone #:</td>
size=15> <td class=left>
</td> <input type=text
</tr>\n"; name=\"formfields[usr_phone]\"
value=\"" . $formfields[usr_phone] . "\"
size=15>
</td>
</tr>\n";
# #
# SSH public key # SSH public key
# #
echo "<tr> echo "<tr>
<td rowspan><center> <td rowspan><center>
Your SSH Pub Key: &nbsp<br> Your SSH Pub Key: &nbsp<br>
[<b>2</b>] [<b>2</b>]
</center></td> </center></td>
<td rowspan><center>Upload (1K max)[<b>3</b>]<br> <td rowspan><center>Upload (1K max)[<b>3</b>]<br>
<b>Or</b><br> <b>Or</b><br>
Insert Key Insert Key
</center></td> </center></td>
<td rowspan> <td rowspan>
<input type=hidden name=MAX_FILE_SIZE value=1024> <input type=hidden name=MAX_FILE_SIZE value=1024>
<input type=file <input type=file
name=usr_keyfile name=usr_keyfile
value=\"" . $_FILES['usr_keyfile']['name'] . "\" value=\"" . $_FILES['usr_keyfile']['name'] .
size=50> "\"
<br> size=50>
<br> <br>
<input type=text <br>
name=\"formfields[usr_key]\" <input type=text
value=\"$formfields[usr_key]\" name=\"formfields[usr_key]\"
size=50 value=\"$formfields[usr_key]\"
maxlength=1024> size=50
</td> maxlength=1024>
</tr>\n"; </td>
</tr>\n";
}
# #
# Password. Note that we do not resend the password. User # Password. Note that we do not resend the password. User
...@@ -273,32 +350,34 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -273,32 +350,34 @@ function SPITFORM($formfields, $returning, $errors)
</tr>\n"; </tr>\n";
} }
# if (! $forwikionly) {
# Project Name: #
# # Project Name:
echo "<tr> #
<td colspan=2>*Project Name:</td> echo "<tr>
<td class=left> <td colspan=2>*Project Name:</td>
<input type=text <td class=left>
name=\"formfields[pid]\" <input type=text
value=\"" . $formfields[pid] . "\" name=\"formfields[pid]\"
size=$TBDB_PIDLEN maxlength=$TBDB_PIDLEN> value=\"" . $formfields[pid] . "\"
</td> size=$TBDB_PIDLEN maxlength=$TBDB_PIDLEN>
</tr>\n"; </td>
</tr>\n";
# #
# Group Name: # Group Name:
# #
echo "<tr> echo "<tr>
<td colspan=2>Group Name:<br> <td colspan=2>Group Name:<br>
(Leave blank unless you <em>know</em> the group name)</td> (Leave blank unless you <em>know</em> the group name)</td>
<td class=left> <td class=left>
<input type=text <input type=text
name=\"formfields[gid]\" name=\"formfields[gid]\"
value=\"" . $formfields[gid] . "\" value=\"" . $formfields[gid] . "\"
size=$TBDB_GIDLEN maxlength=$TBDB_GIDLEN> size=$TBDB_GIDLEN maxlength=$TBDB_GIDLEN>
</td> </td>
</tr>\n"; </tr>\n";
}
echo "<tr> echo "<tr>
<td colspan=3 align=center> <td colspan=3 align=center>
...@@ -315,7 +394,7 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -315,7 +394,7 @@ function SPITFORM($formfields, $returning, $errors)
<a href = 'docwrapper.php3?docname=security.html'> <a href = 'docwrapper.php3?docname=security.html'>
security policies</a> for information security policies</a> for information
regarding passwords and email addresses.\n"; regarding passwords and email addresses.\n";
if (! $returning) { if (!$returning && !$forwikionly) {
echo "<li> If you want us to use your existing ssh public key, echo "<li> If you want us to use your existing ssh public key,
then either paste it in or specify the path to your then either paste it in or specify the path to your
your identity.pub file. <font color=red>NOTE:</font> your identity.pub file. <font color=red>NOTE:</font>
...@@ -342,12 +421,21 @@ function SPITFORM($formfields, $returning, $errors) ...@@ -342,12 +421,21 @@ function SPITFORM($formfields, $returning, $errors)
# The conclusion of a join request. See below. # The conclusion of a join request. See below.
# #
if (isset($_GET['finished'])) { if (isset($_GET['finished'])) {
PAGEHEADER("Apply for Project Membership"); if ($forwikionly)
PAGEHEADER("Wiki Registration");
else
PAGEHEADER("Apply for Project Membership");
# #
# Generate some warm fuzzies. # Generate some warm fuzzies.
# #
if (! $returning) { if ($forwikionly) {
echo "An email message has been sent to your account so we may verify
your email address. Please follow the instructions contained in
that message, which will verify your account, and grant you
access to the Wiki.\n";
}
elseif (! $returning) {
echo "<p> echo "<p>
As a pending user of the Testbed you will receive a key via email. As a pending user of the Testbed you will receive a key via email.
When you receive the message, please follow the instructions When you receive the message, please follow the instructions
...@@ -356,7 +444,8 @@ if (isset($_GET['finished'])) { ...@@ -356,7 +444,8 @@ if (isset($_GET['finished'])) {
<p> <p>
When you have done that, the project leader will be When you have done that, the project leader will be
notified of your application. "; notified of your application. ";
} else { }
else {
echo "<p> echo "<p>
The project leader has been notified of your application. ";