Subject: | Should pass Catalyst log object to Authen::Simple objects |
Hiya.
It would be nice if the Catalyst::Log object was passed to the
Authen::Simple class, so that authentication logging went through the
application.
Please find attached a small patch which does this, and also uses
Catalyst's ensure_class_loaded, rather than needing an additional
dependency on Module::Load.
Cheers
t0m
Subject: | pass_catalyst_log_object.diff |
diff -ur Catalyst-Authentication-Credential-Authen-Simple-0.03/lib/Catalyst/Authentication/Credential/Authen/Simple.pm Catalyst-Authentication-Credential-Authen-Simple.t0m/lib/Catalyst/Authentication/Credential/Authen/Simple.pm
--- Catalyst-Authentication-Credential-Authen-Simple-0.03/lib/Catalyst/Authentication/Credential/Authen/Simple.pm 2009-04-01 20:05:01.000000000 +0100
+++ Catalyst-Authentication-Credential-Authen-Simple.t0m/lib/Catalyst/Authentication/Credential/Authen/Simple.pm 2009-04-03 10:21:32.000000000 +0100
@@ -6,7 +6,7 @@
use warnings;
use Authen::Simple;
-use Module::Load;
+use Catalyst::Utils;
sub new {
my ($class, $config, $app, $realm) = @_;
@@ -16,7 +16,6 @@
unless (defined $config->{'authen'}){
die "No Authen::Simple classes specified for Credential::Authen::Simple in 'authen' key"
}
-
if (ref($config->{'authen'}) ne 'ARRAY') {
$config->{'authen'} = [ $config->{'authen'} ];
}
@@ -25,8 +24,10 @@
foreach my $auth (@{ $config->{'authen'} }){
my $class = "Authen::Simple::$auth->{'class'}";
$app->log->debug("Loading class: $class") if $app->debug;
- load $class;
- push @auth_arr, $class->new(%{ $auth->{'args'} });
+ Catalyst::Utils::ensure_class_loaded($class);
+ my $args = $auth->{'args'} || {};
+ $args->{log} = $app->log;
+ push @auth_arr, $class->new(%$args);
}
$self->{'_config'}->{'password_field'} ||= 'password';
diff -ur Catalyst-Authentication-Credential-Authen-Simple-0.03/Makefile.PL Catalyst-Authentication-Credential-Authen-Simple.t0m/Makefile.PL
--- Catalyst-Authentication-Credential-Authen-Simple-0.03/Makefile.PL 2008-06-28 14:41:26.000000000 +0100
+++ Catalyst-Authentication-Credential-Authen-Simple.t0m/Makefile.PL 2009-04-03 10:11:32.000000000 +0100
@@ -12,8 +12,7 @@
'Test::Simple' => 0.44,
'Test::More' => 0,
'Authen::Simple' => 0,
- 'Module::Load' => 0,
- 'Catalyst::Runtime' => 0,
+ 'Catalyst::Runtime' => '5.7',
'Catalyst::Plugin::Authentication' => '>= 1.0'
},
LICENSE => 'perl'
diff -ur Catalyst-Authentication-Credential-Authen-Simple-0.03/t/lib/Authen/Simple/Stub.pm Catalyst-Authentication-Credential-Authen-Simple.t0m/t/lib/Authen/Simple/Stub.pm
--- Catalyst-Authentication-Credential-Authen-Simple-0.03/t/lib/Authen/Simple/Stub.pm 2008-06-28 14:07:32.000000000 +0100
+++ Catalyst-Authentication-Credential-Authen-Simple.t0m/t/lib/Authen/Simple/Stub.pm 2009-04-03 10:20:50.000000000 +0100
@@ -3,7 +3,7 @@
use strict;
use warnings;
use base 'Authen::Simple::Adapter';
-
+__PACKAGE__->options({});
sub check {
my ( $self, $username, $password ) = @_;