Apache-LoggedAuthDBI
view release on metacpan or search on metacpan
LoggedAuthDBI.pm view on Meta::CPAN
PerlAuthzHandler Apache::AuthDBI::authz
PerlSetVar Auth_DBI_data_source dbi:driver:dsn
PerlSetVar Auth_DBI_username db_username
PerlSetVar Auth_DBI_password db_password
#DBI->connect($data_source, $username, $password)
PerlSetVar Log_ADBI_table login_log
PerlSetVar Log_ADBI_ip_field IPaddress
PerlSetVar Log_ADBI_un_field username
PerlSetVar Log_ADBI_status_field status
PerlSetVar Log_ADBI_time_field timestamped
# data required to access the log table
PerlSetVar Auth_DBI_pwd_table users
PerlSetVar Auth_DBI_uid_field username
PerlSetVar Auth_DBI_pwd_field password
# authentication: SELECT pwd_field FROM pwd_table WHERE uid_field=$user
require valid-user
=head1 DESCRIPTION
This is an extension of Apache::AuthDBI by Edmund Mergl. Its purpose is
to add a degree of protection against brute force attacks and password sharing.
To accomplish this LoggedAuthDBI makes use of a log table that records IP, username,
status and time of any given login attempt handled by this module.
Whenever it is called it will perform four checks:
=over 4
=item *
Did IPaddress 123 make X failed attempts in Y seconds?
(autoreject IP addresses that have too many failed attempts on record)
=item *
Did IPaddress 123 make X attempts in Y seconds?
(if X gets very large while Y is small, the possibility of a brute force
attack taking place is very real indeed)
=item *
Has username foo been rejected X times in Y seconds?
(this check as a means to help against proxy rotation in combination with
brute force attempts)
=item *
Does username foo have logins from X different IPaddresses in Y seconds?
(this would surely indicate password sharing)
=back
Should none of the four checks yield a violation AuthDBI is called and its
return value used without modification.
Otherwise it will redirect to a different filename while returning OK. This
will cause a bruteforce tool to think it was successful in its attempt to
guess a valid login/pass combination and either stop or collect this combination
into its list of valid options.
Consider this module beta ware as it has only seen action in the original
context it was created for and at.
=head1 LOG TABLE
While it is possible that a log table is already in place it might need some
adjustment. See this MySQL CREATE TABLE command to see the required structure/
how to create. Table name and field names are, of course, arbitrary as they are
determined in the .htaccess file.
<mysql>
CREATE TABLE `member_log` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(64) default NULL,
`IPaddress` varchar(15) default NULL,
`status` varchar(15) default NULL,
`timestamped` timestamp(14) NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM
</mysql>
=head1 LIST OF TOKENS
Only the tokens specific to this module are discussed here. For reference
on the remaining tokens consult the documentation on Apache::AuthDBI.
=over 4
=item *
Log_ADBI_table
Name of the table where login records will be kept.
Has to at least contain fields holding IPaddress, username, status and timestamp.
=item *
Log_ADBI_ip_field
Field name of the Log_ADBI_table containing the IPaddress of the login attempt.
=item *
Log_ADBI_un_field
Field name of the Log_ADBI_table containing the username of the login attempt.
=item *
Log_ADBI_status_field
Field name of the Log_ADBI_table containing the status of the login attempt that was made.
=item *
Log_ADBI_time_field
Field name of the Log_ADBI_table containing the timestamp of the login attempt.
=back
( run in 2.077 seconds using v1.01-cache-2.11-cpan-d8267643d1d )