From 50c4bd4145b45a23938c9d1ced75efa39067397f Mon Sep 17 00:00:00 2001 From: moodler <moodler> Date: Tue, 31 Dec 2002 08:45:37 +0000 Subject: [PATCH] More robustness, and some little bug fixes. Also, database module now supports md5 passwords --- admin/auth.php | 14 +++++++++++ auth/db/config.html | 58 +++++++++++++++++++++++++++++++++++++------ auth/db/lib.php | 8 +++--- auth/imap/config.html | 15 +++++++++-- auth/ldap/config.html | 36 +++++++++++++++++++++------ auth/nntp/config.html | 15 ++++++++--- auth/pop3/config.html | 16 +++++++++--- lang/en/auth.php | 3 +++ 8 files changed, 139 insertions(+), 26 deletions(-) diff --git a/admin/auth.php b/admin/auth.php index 5b5e4cfc10..13e5dd29e6 100644 --- a/admin/auth.php +++ b/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 = ""; diff --git a/auth/db/config.html b/auth/db/config.html index efe04cd93a..db36f1b54e 100644 --- a/auth/db/config.html +++ b/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> diff --git a/auth/db/lib.php b/auth/db/lib.php index 45ed5cf0d3..6d9eda0ca0 100644 --- a/auth/db/lib.php +++ b/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' diff --git a/auth/imap/config.html b/auth/imap/config.html index 79089256d4..b8818a3ebd 100644 --- a/auth/imap/config.html +++ b/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") ?> diff --git a/auth/ldap/config.html b/auth/ldap/config.html index aff8268330..65eb78f78b 100644 --- a/auth/ldap/config.html +++ b/auth/ldap/config.html @@ -1,8 +1,28 @@ +<?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") ?> @@ -10,10 +30,10 @@ </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> diff --git a/auth/nntp/config.html b/auth/nntp/config.html index 5b4375e75b..453ffb8a6c 100644 --- a/auth/nntp/config.html +++ b/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") ?> diff --git a/auth/pop3/config.html b/auth/pop3/config.html index 19847cc55f..9e42e351a3 100644 --- a/auth/pop3/config.html +++ b/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") ?> diff --git a/lang/en/auth.php b/lang/en/auth.php index 07f1718d1d..804379631a 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -9,6 +9,7 @@ $string['auth_dbfielduser'] = "Name of the field containing usernames"; $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['changepassword'] = "Change password URL"; $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."; ?> -- 2.39.5