Current time: 05-17-2024, 06:34 PM Hello There, Guest! (LoginRegister)


Post Reply 
Awstats password protection
Author Message
memic Offline
Newbie
*

Posts: 6
Joined: Jun 2008
Reputation: 0
Post: #47
RE: Awstats password protection
i wrote a little script to create a htpasswd file for awstats access,
my Apache Directory in /etc/apache2/sites-enabled/01_awstats.conf looks like this:

<Directory /usr/lib/cgi-bin>
Options +ExecCGI
DirectoryIndex awstats.pl
Order allow,deny
Allow from all

AuthType Basic
AuthName "AWStats"
AuthUserFile /etc/apache2/awstatsusers
Require valid-user <- no users needed here since this is done in the awstats config files
</Directory>

I changed the template /etc/ispcp/awstats/awstats.ispcp_tpl.conf, the same way i have seen this in post before:

AllowAccessFromWebToAuthenticatedUsersOnly="1"
AllowAccessFromWebToFollowingAuthenticatedUsers="{DOMAIN_NAME}"

My first idea was to use the md5 sums from the admin table
to create the htpasswd file, but there is the problem that
md5sum which htpasswd creates are salted, so there is no
way to use the existing hashes for authentication.

Here is the script, it does the job of creating a password
for every domain in the /etc/apache2/awstatsusers file.
Attention the file /etc/apache2/awstatsusers gets deleted every
time, and new passwords are generated.
Fell free to edit/copy do whatever..

#!/usr/bin/perl -w

use DBI;

my $dbh = DBI->connect('dbi:mysql:ispcp:localhost:3306','root','yourpassword',{ RaiseError => 1, AutoCommit => 1});

my $sql = qq{select admin_name from admin;};
my $sth = $dbh->prepare($sql);
$sth->execute();

my $mypass="";
unlink ("/etc/apache2/awstatsusers");
system ("touch /etc/apache2/awstatsusers");
while(@ergebnis=$sth->fetchrow_array)
{

$mypass=randomPassword();
print $ergebnis[0], ":", $mypass, "\n";

system "htpasswd -mb /etc/apache2/awstatsusers $ergebnis[0] $mypass &> /dev/null";
}
sub randomPassword {
my $password;
my $_rand;

my $password_length = $_[0];
if (!$password_length) {
$password_length = 10;
}

my @chars = split(" ", "a b c d e f g h i j k l m n o
p q r s t u v w x y z
0 1 2 3 4 5 6 7 8 9");

srand;

for (my $i=0; $i <= $password_length ;$i++) {
$_rand = int(rand 36);
$password .= $chars[$_rand];
}

return $password;
}

---------

maybe a new table for the awstats user should be added, with
the possibilty to change the the password via webinterface, as
default password the login password for the domain.

memic
06-22-2008 08:11 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Awstats password protection - Cube - 10-18-2007, 06:05 AM
RE: Awstats password protection - RatS - 10-18-2007, 07:52 AM
RE: Awstats password protection - Cube - 10-18-2007, 08:32 AM
RE: Awstats password protection - raphael - 10-18-2007, 09:48 AM
RE: Awstats password protection - BioALIEN - 10-18-2007, 07:08 PM
RE: Awstats password protection - robmorin - 10-24-2007, 12:43 AM
RE: Awstats password protection - BeNe - 10-25-2007, 10:29 PM
RE: Awstats password protection - BeNe - 10-25-2007, 11:42 PM
RE: Awstats password protection - BeNe - 10-28-2007, 03:10 AM
RE: Awstats password protection - Cube - 11-01-2007, 01:42 AM
RE: Awstats password protection - jmeyerdo - 11-01-2007, 05:26 AM
RE: Awstats password protection - BeNe - 11-01-2007, 06:40 AM
RE: Awstats password protection - Mike - 12-26-2007, 07:35 AM
RE: Awstats password protection - divion - 01-09-2008, 03:21 PM
RE: Awstats password protection - BeNe - 01-23-2008, 05:50 AM
RE: Awstats password protection - BeNe - 01-24-2008, 12:12 AM
RE: Awstats password protection - BioALIEN - 01-24-2008, 12:27 AM
RE: Awstats password protection - BeNe - 01-24-2008, 06:10 AM
RE: Awstats password protection - Cube - 02-19-2008, 10:22 AM
RE: Awstats password protection - Kwik - 02-22-2008, 07:03 PM
RE: Awstats password protection - rauschr - 05-13-2008, 07:47 AM
RE: Awstats password protection - BeNe - 04-16-2008, 05:25 PM
RE: Awstats password protection - ghislain - 04-16-2008, 09:48 PM
RE: Awstats password protection - Eminos - 04-23-2008, 12:44 AM
RE: Awstats password protection - Eminos - 04-24-2008, 08:52 PM
RE: Awstats password protection - Cube - 04-25-2008, 05:29 AM
RE: Awstats password protection - momo - 06-14-2008, 12:46 AM
RE: Awstats password protection - BeNe - 06-16-2008, 03:34 AM
RE: Awstats password protection - Eminos - 06-16-2008, 03:36 AM
RE: Awstats password protection - Cube - 06-16-2008, 04:00 AM
RE: Awstats password protection - Eminos - 06-16-2008, 04:01 AM
RE: Awstats password protection - momo - 06-17-2008, 02:26 AM
RE: Awstats password protection - Eminos - 06-17-2008, 03:29 AM
RE: Awstats password protection - momo - 06-17-2008, 04:46 AM
RE: Awstats password protection - Eminos - 06-17-2008, 04:50 AM
RE: Awstats password protection - momo - 06-17-2008, 05:01 AM
RE: Awstats password protection - memic - 06-22-2008 08:11 AM
RE: Awstats password protection - RatS - 08-09-2008, 07:39 PM
RE: Awstats password protection - obey - 08-12-2008, 07:18 PM
RE: Awstats password protection - RatS - 08-13-2008, 05:31 AM
RE: Awstats password protection - lbm - 09-09-2008, 04:04 AM
RE: Awstats password protection - BeNe - 09-09-2008, 06:07 AM
RE: Awstats password protection - lbm - 09-10-2008, 08:27 PM
RE: Awstats password protection - noel - 10-27-2008, 11:41 AM
RE: Awstats password protection - noel - 10-27-2008, 10:21 PM
RE: Awstats password protection - simple - 11-24-2008, 04:55 AM
RE: Awstats password protection - sci2tech - 11-24-2008, 05:15 AM
RE: Awstats password protection - simple - 11-25-2008, 06:57 PM
RE: Awstats password protection - sci2tech - 11-26-2008, 02:02 AM
RE: Awstats password protection - sci2tech - 11-27-2008, 09:21 AM
RE: Awstats password protection - Cube - 11-28-2008, 05:07 AM
RE: Awstats password protection - sci2tech - 11-28-2008, 06:25 AM
RE: Awstats password protection - momo - 01-16-2009, 06:36 AM
RE: Awstats password protection - momo - 01-20-2009, 08:38 AM
RE: Awstats password protection - simple - 01-20-2009, 08:44 AM
RE: Awstats password protection - bulforce - 01-29-2009, 04:31 PM
RE: Awstats password protection - BeNe - 01-29-2009, 04:46 PM
RE: Awstats password protection - sci2tech - 01-29-2009, 10:26 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)