Search squid archive

Joomla DB authentication support hits Squid! :)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



HI all

As a requirement of one client, he wants to use joomla user database to let 
squid authenticate.

I did patch squid_db_auth that Henrik has written in order to support joomla 
hash conditions.  

I did add one usefull option to script

--joomla

in order to activate joomla hashing.  Other options are identical.  Please 
test :)

Ammos, I'd like if you can include this in 3.1.2

LD
--- helpers/basic_auth/DB/squid_db_auth.in	2010-03-29 12:02:56.000000000 +0200
+++ helpers/basic_auth/DB/squid_db_auth.in.dlucio	2010-04-22 22:27:00.000000000 +0200
@@ -3,6 +3,7 @@
 use DBI;
 use Getopt::Long;
 use Pod::Usage;
+use Digest::MD5 qw(md5 md5_hex md5_base64);
 $|=1;
 
 =pod
@@ -22,6 +23,8 @@
 my $db_cond = "enabled = 1";
 my $plaintext = 0;
 my $persist = 0;
+my $isjoomla = 0;
+my $debug = 0;
 
 =pod
 
@@ -85,9 +88,12 @@
 	'cond=s' => \$db_cond,
 	'plaintext' => \$plaintext,
 	'persist' => \$persist,
+	'joomla' => \$isjoomla,
+	'debug' => \$debug,
 	);
 
-my ($_dbh, $_sth);
+$db_cond = "enabled = 1" if $isjoomla;
+
 
 sub close_db()
 {
@@ -113,10 +119,17 @@
 {
     my ($password, $key) = @_;
 
-    return 1 if crypt($password, $key) eq $key;
+    if ($isjoomla){
+        my salt;
+        my $key2;
+        ($key2,$salt) = (/:/, $key);
+        return 1 if md5_hex($password.$salt).':'.$salt eq $key;
+    }
+    else{
+        return 1 if crypt($password, $key) eq $key;
     
-    return 1 if $plaintext && $password eq $key;
-
+        return 1 if $plaintext && $password eq $key;
+    }
     return 0;
 }
 
@@ -155,8 +168,9 @@
 =head1 COPYRIGHT
 
 Copyright (C) 2007 Henrik Nordstrom <henrik@xxxxxxxxxxxxxxxxxxx>
+Copyright (C) 2010 Luis Daniel Lucio Quiroz <dlucio@xxxxxxxxxxx> (Joomla support)
+
 This program is free software. You may redistribute copies of it under the
 terms of the GNU General Public License version 2, or (at youropinion) any
 later version.
-
 =cut

[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux