Skip to content
Browse files

More robustness, and some little bug fixes.

Also, database module now supports md5 passwords
  • Loading branch information...
1 parent f53af94 commit 50c4bd4145b45a23938c9d1ced75efa39067397f moodler committed Dec 31, 2002
Showing with 139 additions and 26 deletions.
  1. +14 −0 admin/auth.php
  2. +51 −7 auth/db/config.html
  3. +5 −3 auth/db/lib.php
  4. +13 −2 auth/imap/config.html
  5. +28 −8 auth/ldap/config.html
  6. +12 −3 auth/nntp/config.html
  7. +13 −3 auth/pop3/config.html
  8. +3 −0 lang/en/auth.php
View
14 admin/auth.php
@@ -59,6 +59,20 @@
if (! isset($config->guestloginbutton)) {
$config->guestloginbutton = 1;
}
+ if (! isset($config->auth_instructions)) {
+ $config->auth_instructions = "";
+ }
+ if (! isset($config->changepassword)) {
+ $config->changepassword = "";
+ }
+ $user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
+
+ foreach ($user_fields as $user_field) {
+ $user_field = "auth_user_$user_field";
+ if (! isset($config->$user_field)) {
+ $config->$user_field = "";
+ }
+ }
if (empty($focus)) {
$focus = "";
View
58 auth/db/config.html
@@ -1,8 +1,37 @@
+<?PHP
+ if (!isset($config->auth_dbhost)) {
+ $config->auth_dbhost = "localhost";
+ }
+ if (!isset($config->auth_dbtype)) {
+ $config->auth_dbtype = "mysql";
+ }
+ if (!isset($config->auth_dbname)) {
+ $config->auth_dbname = "";
+ }
+ if (!isset($config->auth_dbuser)) {
+ $config->auth_dbuser = "";
+ }
+ if (!isset($config->auth_dbpass)) {
+ $config->auth_dbpass = "";
+ }
+ if (!isset($config->auth_dbtable)) {
+ $config->auth_dbtable = "";
+ }
+ if (!isset($config->auth_dbfielduser)) {
+ $config->auth_dbfielduser = "";
+ }
+ if (!isset($config->auth_dbfieldpass)) {
+ $config->auth_dbfieldpass = "";
+ }
+ if (!isset($config->auth_dbpasstype)) {
+ $config->auth_dbpasstype = "plaintext";
+ }
+?>
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_dbhost:</TD>
<TD>
<INPUT name=auth_dbhost TYPE=text SIZE=30 VALUE="<?=$config->auth_dbhost?>">
- <? formerr($err["auth_dbhost"]); ?>
+ <? if (isset($err["auth_dbhost"])) formerr($err["auth_dbhost"]); ?>
</TD>
<TD>
<? print_string("auth_dbhost","auth") ?>
@@ -29,7 +58,7 @@
<TD ALIGN=RIGHT><P>auth_dbname:</TD>
<TD>
<INPUT name=auth_dbname TYPE=text SIZE=30 VALUE="<?=$config->auth_dbname?>">
- <? formerr($err["auth_dbname"]); ?>
+ <? if (isset($err["auth_dbname"]))formerr($err["auth_dbname"]); ?>
</TD>
<TD>
<? print_string("auth_dbname","auth") ?>
@@ -40,7 +69,7 @@
<TD ALIGN=RIGHT><P>auth_dbuser:</TD>
<TD>
<INPUT name=auth_dbuser TYPE=text SIZE=30 VALUE="<?=$config->auth_dbuser?>">
- <? formerr($err["auth_dbuser"]); ?>
+ <? if (isset($err["auth_dbuser"])) formerr($err["auth_dbuser"]); ?>
</TD>
<TD>
<? print_string("auth_dbuser","auth") ?>
@@ -51,7 +80,7 @@
<TD ALIGN=RIGHT><P>auth_dbpass:</TD>
<TD>
<INPUT name="auth_dbpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbpass?>">
- <? formerr($err["auth_dbpass"]); ?>
+ <? if (isset($err["auth_dbpass"])) formerr($err["auth_dbpass"]); ?>
</TD>
<TD>
<? print_string("auth_dbpass","auth") ?>
@@ -62,7 +91,7 @@
<TD ALIGN=RIGHT><P>auth_dbtable:</TD>
<TD>
<INPUT name="auth_dbtable" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbtable?>">
- <? formerr($err["auth_dbtable"]); ?>
+ <? if (isset($err["auth_dbtable"])) formerr($err["auth_dbtable"]); ?>
</TD>
<TD>
<? print_string("auth_dbtable","auth") ?>
@@ -73,7 +102,7 @@
<TD ALIGN=RIGHT><P>auth_dbfielduser:</TD>
<TD>
<INPUT name="auth_dbfielduser" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfielduser?>">
- <? formerr($err["auth_dbfielduser"]); ?>
+ <? if (isset($err["auth_dbfielduser"])) formerr($err["auth_dbfielduser"]); ?>
</TD>
<TD>
<? print_string("auth_dbfielduser","auth") ?>
@@ -84,13 +113,28 @@
<TD ALIGN=RIGHT><P>auth_dbfieldpass:</TD>
<TD>
<INPUT name="auth_dbfieldpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfieldpass?>">
- <? formerr($err["auth_dbfieldpass"]); ?>
+ <? if (isset($err["auth_dbfieldpass"])) formerr($err["auth_dbfieldpass"]); ?>
</TD>
<TD>
<? print_string("auth_dbfieldpass","auth") ?>
</TD>
</TR>
+<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
+ <TD ALIGN=RIGHT><P>auth_dbpasstype:</TD>
+ <TD>
+ <? $passtype["plaintext"] = get_string("plaintext", "auth");
+ $passtype["md5"] = get_string("md5", "auth");
+ choose_from_menu($passtype, "auth_dbpasstype", $config->auth_dbpasstype, "");
+ ?>
+
+ </TD>
+ <TD>
+ <? print_string("auth_dbpasstype","auth") ?>
+ </TD>
+</TR>
+
+
<TR>
<TD ALIGN=RIGHT><P><? print_string("firstname") ?>:</TD>
<TD>
View
8 auth/db/lib.php
@@ -1,9 +1,6 @@
<?PHP // $Id$
// Authentication by looking up an external database table
-// This code is completely untested so far - IT NEEDS TESTERS!
-// Looks like it should work though ...
-
function auth_user_login ($username, $password) {
// Returns true if the username and password work
@@ -15,6 +12,11 @@ function auth_user_login ($username, $password) {
$authdb = &ADONewConnection();
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
+ switch ($CFG->auth_dbpasstype) { // Re-format password accordingly
+ case "md5":
+ $password = md5($password);
+ break;
+ }
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
WHERE $CFG->auth_dbfielduser = '$username'
View
15 auth/imap/config.html
@@ -1,8 +1,19 @@
+<?PHP
+ if (!isset($config->auth_imaphost)) {
+ $config->auth_imaphost = "127.0.0.1";
+ }
+ if (!isset($config->auth_imaptype)) {
+ $config->auth_imaptype = "imap";
+ }
+ if (!isset($config->auth_imapport)) {
+ $config->auth_imapport = "143";
+ }
+?>
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_imaphost:</TD>
<TD>
<INPUT name=auth_imaphost TYPE=text SIZE=30 VALUE="<?=$config->auth_imaphost?>">
- <? formerr($err["ldap_host_url"]); ?>
+ <? if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
</TD>
<TD>
<? print_string("auth_imaphost","auth") ?>
@@ -28,7 +39,7 @@
<TD ALIGN=RIGHT><P>auth_imapport:</TD>
<TD>
<INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_imapport?>">
- <? formerr($err["auth_imapport"]); ?>
+ <? if (isset($err["auth_imapport"])) formerr($err["auth_imapport"]); ?>
</TD>
<TD>
<? print_string("auth_imapport","auth") ?>
View
36 auth/ldap/config.html
@@ -1,19 +1,39 @@
+<?PHP
+ if (!isset($config->ldap_host_url)) {
+ $config->ldap_host_url = "";
+ }
+ if (!isset($config->ldap_contexts)) {
+ $config->ldap_contexts = "";
+ }
+ if (!isset($config->ldap_user_attribute)) {
+ $config->ldap_user_attribute = "";
+ }
+ if (!isset($config->ldap_search_sub)) {
+ $config->ldap_search_sub = "";
+ }
+ if (!isset($config->ldap_bind_dn)) {
+ $config->ldap_bind_dn = "";
+ }
+ if (!isset($config->ldap_bind_pw)) {
+ $config->ldap_bind_pw = "";
+ }
+?>
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
<TD>
<INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?=$config->ldap_host_url?>">
- <? formerr($err["ldap_host_url"]); ?>
+ <? if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
</TD>
<TD>
<? print_string("auth_ldap_host_url","auth") ?>
</TD>
</TR>
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
- <TD ALIGN=RIGHT><P>ldap_user_context:</TD>
+ <TD ALIGN=RIGHT><P>ldap_contexts:</TD>
<TD>
<INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?=$config->ldap_contexts?>">
- <? formerr($err["ldap_contexts"]); ?>
+ <? if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
</TD>
<TD>
<? print_string("auth_ldap_contexts","auth") ?>
@@ -24,7 +44,7 @@
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
<TD>
<INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?=$config->ldap_user_attribute?>">
- <? formerr($err["ldap_user_attribute"]); ?>
+ <? if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
</TD>
<TD>
<? print_string("auth_ldap_user_attribute","auth") ?>
@@ -35,7 +55,7 @@
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
<TD>
<INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?=$config->ldap_search_sub?>">
- <? formerr($err["ldap_search_sub"]); ?>
+ <? if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
</TD>
<TD>
<? print_string("auth_ldap_search_sub","auth") ?>
@@ -46,17 +66,17 @@
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
<TD>
<INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_dn?>">
- <? formerr($err["ldap_bind_dn"]); ?>
+ <? if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
</TD><TD>
<? print_string("auth_ldap_bind_dn","auth") ?>
</TD>
</TR>
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
- <TD ALIGN=RIGHT><P>ldap_bind_password:</TD>
+ <TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
<TD>
<INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_pw?>">
- <? formerr($err["ldap_bind_pw"]); ?>
+ <? if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
</TD><TD>
<? print_string("auth_ldap_bind_pw","auth") ?>
</TD>
View
15 auth/nntp/config.html
@@ -1,8 +1,17 @@
+<?PHP
+ if (!isset($config->auth_nntphost)) {
+ $config->auth_nntphost = "127.0.0.1";
+ }
+ if (!isset($config->auth_nntpport)) {
+ $config->auth_nntpport = "119";
+ }
+?>
+
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_nntphost:</TD>
<TD>
<INPUT name="auth_nntphost" TYPE="text" SIZE=30 VALUE="<?=$config->auth_nntphost?>">
- <? formerr($err["ldap_nntphost"]); ?>
+ <? if (isset($err["auth_nntphost"])) formerr($err["auth_nntphost"]); ?>
</TD>
<TD>
<? print_string("auth_nntphost","auth") ?>
@@ -12,8 +21,8 @@
<TR VALIGN=TOP BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_nntpport:</TD>
<TD>
- <INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
- <? formerr($err["auth_nntpport"]); ?>
+ <INPUT name=auth_nntpport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
+ <? if (isset($err["auth_nntpport"])) formerr($err["auth_nntpport"]); ?>
</TD>
<TD>
<? print_string("auth_nntpport","auth") ?>
View
16 auth/pop3/config.html
@@ -1,8 +1,19 @@
+<?PHP
+ if (!isset($config->auth_pop3host)) {
+ $config->auth_pop3host = "127.0.0.1";
+ }
+ if (!isset($config->auth_pop3type)) {
+ $config->auth_pop3type = "pop3";
+ }
+ if (!isset($config->auth_pop3port)) {
+ $config->auth_pop3port = "110";
+ }
+?>
<tr valign="top" BGCOLOR="<?=$THEME->cellheading2 ?>">
<TD ALIGN=RIGHT><P>auth_pop3host:</TD>
<TD>
<INPUT name=auth_pop3host TYPE=text SIZE=30 VALUE="<?=$config->auth_pop3host?>">
- <? formerr($err["ldap_host_url"]); ?>
+ <? if (isset($err["auth_pop3host"])) formerr($err["auth_pop3host"]); ?>
</TD>
<TD>
<? print_string("auth_pop3host","auth") ?>
@@ -18,7 +29,6 @@
}
choose_from_menu($pop3options, "auth_pop3type", $config->auth_pop3type, "");
?>
- <? formerr($err["auth_pop3type"]); ?>
</TD>
<TD>
<? print_string("auth_pop3type","auth") ?>
@@ -29,7 +39,7 @@
<TD ALIGN=RIGHT><P>auth_pop3port:</TD>
<TD>
<INPUT name=auth_pop3port TYPE=text SIZE=6 VALUE="<?=$config->auth_pop3port?>">
- <? formerr($err["auth_pop3port"]); ?>
+ <? if (isset($err["auth_pop3port"])) formerr($err["auth_pop3port"]); ?>
</TD>
<TD>
<? print_string("auth_pop3port","auth") ?>
View
3 lang/en/auth.php
@@ -9,6 +9,7 @@
$string['auth_dbhost'] = "The computer hosting the database server.";
$string['auth_dbname'] = "Name of the database itself";
$string['auth_dbpass'] = "Password matching the above username";
+$string['auth_dbpasstype'] = "Specify the format that the password field is using. MD5 encryption is useful for connecting to other common web applications like PostNuke";
$string['auth_dbtable'] = "Name of the table in the database";
$string['auth_dbtitle'] = "Use an external database";
$string['auth_dbtype'] = "The database type (See the <A HREF=../lib/adodb/readme.htm#drivers>ADOdb documentation</A> for details)";
@@ -52,6 +53,8 @@
$string['changepasswordhelp'] = "Here you can specify a location at which your users can recover or change their username/password if they've forgotten it. This will be provided to users as a button on the login page and their user page. if you leave this blank the button will not be printed.";
$string['chooseauthmethod'] = "Choose an authentication method: ";
$string['guestloginbutton'] = "Guest login button";
+$string['md5'] = "MD5 encryption";
+$string['plaintext'] = "Plain text";
$string['showguestlogin'] = "You can hide or show the guest login button on the login page.";
?>

0 comments on commit 50c4bd4

Please sign in to comment.
Something went wrong with that request. Please try again.