Apache-LoggedAuthDBI
view release on metacpan or search on metacpan
print STDERR "$prefix not configured, return DECLINED\n" if $Apache::AuthDBI::DEBUG > 1;
return MP2 ? Apache2::Const::DECLINED() : Apache::Constants::DECLINED();
}
# do we want Windows-like case-insensitivity?
$user_sent = lc($user_sent) if $Attr->{uidcasesensitive} eq "off";
# select code to return if authorization is denied:
my ($authz_denied);
if (MP2) {
$authz_denied = $Attr->{expeditive} eq 'on' ? Apache2::Const::FORBIDDEN() : Apache2::Const::AUTH_REQUIRED();
} else {
$authz_denied = $Attr->{expeditive} eq 'on' ? Apache::Constants::FORBIDDEN() : Apache::Constants::AUTH_REQUIRED();
}
# check if requirements exists
my ($ary_ref) = $r->requires;
unless ($ary_ref) {
if ($Attr->{authoritative} eq 'on') {
$r->log_reason("user $user_sent denied, no access rules specified (DBI-Authoritative)", $r->uri);
if ($authz_denied == MP2 ? Apache2::Const::AUTH_REQUIRED() : Apache::Constants::AUTH_REQUIRED()) {
$r->note_basic_auth_failure;
}
($user, $pass) = $drh->default_user($user, $pass, $attr)
if !(defined $user && defined $pass);
$attr->{Username} = $user; # store username as attribute
my $connect_closure = sub {
my ($old_dbh, $override_attr) = @_;
my $attr = {
# copy so we can edit them each time we're called
%attributes,
# merge in modified attr in %$old_dbh, this should also copy in
# the dbi_connect_closure attribute so we can reconnect again.
%{ $override_attr || {} },
};
#warn "connect_closure: ".Data::Dumper::Dumper([\%attributes, $override_attr]);
my $dbh;
unless ($dbh = $drh->$connect_meth($dsn, $user, $pass, $attr)) {
$user = '' if !defined $user;
# DBD::Foo::db->install_method("foo_mumble", { usage => [...], options => '...' });
my ($class, $method, $attr) = @_;
Carp::croak("Class '$class' must begin with DBD:: and end with ::db or ::st")
unless $class =~ /^DBD::(\w+)::(dr|db|st)$/;
my ($driver, $subtype) = ($1, $2);
Carp::croak("invalid method name '$method'")
unless $method =~ m/^([a-z]+_)\w+$/;
my $prefix = $1;
my $reg_info = $dbd_prefix_registry->{$prefix};
Carp::croak("method name prefix '$prefix' is not registered") unless $reg_info;
my %attr = %{$attr||{}}; # copy so we can edit
# XXX reformat $attr as needed for _install_method
my ($caller_pkg, $filename, $line) = caller;
DBI->_install_method("DBI::${subtype}::$method", "$filename at line $line", \%attr);
}
sub parse_trace_flags {
my ($h, $spec) = @_;
my $level = 0;
my $flags = 0;
my @unknown;
=item C<dump_results>
$rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);
Fetches all the rows from C<$sth>, calls C<DBI::neat_list> for each row, and
prints the results to C<$fh> (defaults to C<STDOUT>) separated by C<$lsep>
(default C<"\n">). C<$fsep> defaults to C<", "> and C<$maxlen> defaults to 35.
This method is designed as a handy utility for prototyping and
testing queries. Since it uses L</neat_list> to
format and edit the string for reading by humans, it is not recomended
for data transfer applications.
=back
=head2 Statement Handle Attributes
This section describes attributes specific to statement handles. Most
of these attributes are read-only.
4 - As above, adding more detailed information from the driver.
5 to 15 - As above but with more and more obscure information.
Trace level 1 is best for a simple overview of what's happening.
Trace level 2 is a good choice for general purpose tracing.
Levels 3 and above are best reserved for investigating a specific
problem, when you need to see "inside" the driver and DBI.
The trace output is detailed and typically very useful. Much of the
trace output is formatted using the L</neat> function, so strings
in the trace output may be edited and truncated by that function.
=head2 Trace Flags
Trace I<flags> are used to enable tracing of specific activities
within the DBI and drivers. The DBI defines some trace flags and
drivers can define others. DBI trace flag names begin with a capital
letter and driver specific names begin with a lowercase letter, as
usual.
Curently the DBI only defines two trace flags:
Georg Rehfeld, Steve Sizemore, Ron Pool, Jon Meek, Tom Christiansen,
Steve Baumgarten, Randal Schwartz, and a whole lot more.
Then, of course, there are the poor souls who have struggled through
untold and undocumented obstacles to actually implement DBI drivers.
Among their ranks are Jochen Wiedmann, Alligator Descartes, Jonathan
Leffler, Jeff Urlwin, Michael Peppler, Henrik Tougaard, Edwin Pratomo,
Davide Migliavacca, Jan Pazdziora, Peter Haworth, Edmund Mergl, Steve
Williams, Thomas Lowery, and Phlip Plumlee. Without them, the DBI would
not be the practical reality it is today. I'm also especially grateful
to Alligator Descartes for starting work on the first edition of the
"Programming the Perl DBI" book and letting me jump on board.
The DBI and DBD::Oracle were originally developed while I was Technical
Director (CTO) of the Paul Ingram Group (www.ig.co.uk). So I'd
especially like to thank Paul for his generosity and vision in
supporting this work for many years.
=head1 CONTRIBUTING
As you can see above, many people have contributed to the DBI and
LoggedAuthDBI.pm view on Meta::CPAN
=head1 CONFIGURATION
The module should be loaded upon startup of the Apache daemon.
Add the following line to your httpd.conf:
PerlModule Apache::LoggedAuthDBI
Also, copy the following HTML files to the document root of Apache. These are needed
as this module will redirect to these resources in case of detected perpetration. Using
your own is perfectly okay as long as you either keep the naming or edit the filenames
in the module.
=over 4
=item *
blocked.html
=item *
brute_force.html
( run in 0.420 second using v1.01-cache-2.11-cpan-de7293f3b23 )