CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/0000755000076500007650000000000010326301135024123 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/Build.PL0000644000076500007650000000136510324557267025445 0ustar ssorichessoriche00000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'CGI::Application::Plugin::Authentication::Driver::CDBI', license => 'perl', create_makefile_pl => 'traditional', create_readme => 1, dist_author => 'Shawn Sorichetti ', dist_version_from => 'lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm', requires => { 'Test::More' => 0, 'CGI::Application::Plugin::Authentication' => 0.06, 'Class::DBI' => 0, 'DBD::SQLite' => 0, }, add_to_cleanup => ['CGI-Application-Plugin-Authentication-Driver-CDBI-*'], ); $builder->create_build_script(); CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/Changes0000644000076500007650000000022510310350615025415 0ustar ssorichessoriche00000000000000Revision history for CGI-Application-Plugin-Authentication-Driver-CDBI 0.01 Date/time First version, released on an unsuspecting world. CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/0000755000076500007650000000000010326301135024671 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/0000755000076500007650000000000010326301135025273 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/0000755000076500007650000000000010326301135027536 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/0000755000076500007650000000000010326301135030774 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/Authentication/0000755000076500007650000000000010326301135033753 5ustar ssorichessoriche00000000000000././@LongLink0000644000076500007650000000015110326301135011325 Lustar 00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/Authentication/Driver/CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/Authentication/Dri0000755000076500007650000000000010326301135034412 5ustar ssorichessoriche00000000000000././@LongLink0000644000076500007650000000016010326301135011325 Lustar 00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pmCGI-Application-Plugin-Authentication-Driver-CDBI-0.02/lib/CGI/Application/Plugin/Authentication/Dri0000644000076500007650000001051610325557511034431 0ustar ssorichessoriche00000000000000package CGI::Application::Plugin::Authentication::Driver::CDBI; use warnings; use strict; use base 'CGI::Application::Plugin::Authentication::Driver'; =head1 NAME CGI::Application::Plugin::Authentication::Driver::CDBI - Class::DBI Authentication Driver =head1 VERSION Version 0.02 =cut our $VERSION = '0.02'; =head1 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authentication; __PACKAGE__->authen->config( DRIVER => [ 'CDBI', CLASS => 'My::CDBI::Users', FIELD_METHODS => [qw(user MD5:passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], ); =head1 DESCRIPTION This Authentication driver uses the Class::DBI module to allow you to authenticate against any Class::DBI class. =head1 PARAMETERS The Class::DBI authentication driver accepts the following required parameters. =head2 CLASS (required) Specifies the Class::DBI class to use for authentication. This class must be loaded prior to use. =head2 FIELD_METHODS (required) FIELD_METHODS is an arrayref of the methods in the Class::DBI class specified by CLASS to be used during authentication. The order of these methods needs to match the order of the CREDENTIALS. For example, if CREDENTIALS is set to: CREDENTIALS => [qw(auth_user auth_domain auth_password)] Then FIELD_METHODS must be set to: FIELD_METHODS => [qw(userid domain password)] FIELD_METHODS supports filters as specified by CGI::Application::Plugin::Authentication::Driver =head1 METHODS =head2 verify_credentials This method will test the provided credentials against the values found in the database, according to the Driver configuration. =cut sub verify_credentials { my $self = shift; my @creds = @_; my @_options=$self->options; die "The Class::DBI driver requires a hash of options" if @_options % 2; my %options=@_options; my $cdbiclass=$options{CLASS}; die "CLASS option must be set." unless($cdbiclass); return unless(scalar(@creds) eq scalar(@{$options{FIELD_METHODS}})); my @crednames=@{$self->authen->credentials}; my %search; my %compare; my $i=0; # There's a lot of remapping lists/arrays into hashes here # Most of this is due to needing a hash to perform a search, # and another hash to perform comparisions if the search is # encrypted. Also verify that columns that exist have been specified. for(@{$options{FIELD_METHODS}}) { $search{$_}=$creds[$i] unless /:/; $compare{$_}=$creds[$i] if /:/; my $column=$self->strip_field_names($_); die "Column $column not in $cdbiclass" unless($cdbiclass->can($column)); $i++; } my @users=$options{CLASS}->search( %search ); return unless(@users); # We want to return the value of the first column specified. # Could probably just return $creds[0] as that value should match # but I've chosen to return what's in the DB. my $field = ( @{ $options{FIELD_METHODS} } )[0]; if (%compare) { foreach my $encoded ( keys(%compare) ) { my $column = $self->strip_field_names($encoded); # No point checking the rest of the columns if any of the encoded ones # do not match. return unless ( $self->check_filtered( $encoded, $compare{$encoded}, $users[0]->$column ) ); } } # If we've made it this far, we have a valid user. Set the user object and # Return the value of the first credentail. return $users[0]->$field; } =head1 SEE ALSO L, L, perl(1) =head1 AUTHOR Shawn Sorichetti, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 ACKNOWLEDGEMENTS Special thanks to Cees Hek for writing CGI::Application::Plugin::Authentication and his assistance in writing this module. =head1 COPYRIGHT & LICENSE Copyright 2005 Shawn Sorichetti, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of CGI::Application::Plugin::Authentication::Driver::CDBI CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/Makefile.PL0000644000076500007650000000116610325555374026120 0ustar ssorichessoriche00000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'CGI::Application::Plugin::Authentication::Driver::CDBI', 'VERSION_FROM' => 'lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'DBD::SQLite' => 0, 'Class::DBI' => 0, 'CGI::Application::Plugin::Authentication' => '0.06' } ) ; CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/MANIFEST0000644000076500007650000000056010325556427025274 0ustar ssorichessoriche00000000000000Build.PL Changes lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm Makefile.PL MANIFEST META.yml # Will be created by "make dist" README t/00-load.t t/authenticate.t t/authenticate_crypt.t t/authenticate_md5.t t/lib/TestAppAuthcrypt.pm t/lib/TestAppAuthenticate.pm t/lib/TestAppAuthMD5.pm t/lib/TestAppAuthPlain.pm t/lib/TestUsers.pm t/pod-coverage.t t/pod.t CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/META.yml0000644000076500007650000000104010326301134025366 0ustar ssorichessoriche00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: CGI-Application-Plugin-Authentication-Driver-CDBI version: 0.02 version_from: lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm installdirs: site requires: CGI::Application::Plugin::Authentication: 0.06 Class::DBI: 0 DBD::SQLite: 0 Test::More: 0 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/README0000644000076500007650000000461310325555374025026 0ustar ssorichessoriche00000000000000NAME CGI::Application::Plugin::Authentication::Driver::CDBI - Class::DBI Authentication Driver VERSION Version 0.01_01 SYNOPSIS use base qw(CGI::Application); use CGI::Application::Plugin::Authentication; __PACKAGE__->authen->config( DRIVER => [ 'CDBI', CLASS => 'My::CDBI::Users', FIELD_METHODS => [qw(user MD5:passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], ); DESCRIPTION This Authentication driver uses the Class::DBI module to allow you to authenticate against any Class::DBI class. PARAMETERS The Class::DBI authentication driver accepts the following required parameters. CLASS (required) Specifies the Class::DBI class to use for authentication. This class must be loaded prior to use. FIELD_METHODS (required) FIELD_METHODS is an arrayref of the methods in the Class::DBI class specified by CLASS to be used during authentication. The order of these methods needs to match the order of the CREDENTIALS. For example, if CREDENTIALS is set to: CREDENTIALS => [qw(auth_user auth_domain auth_password)] Then FIELD_METHODS must be set to: FIELD_METHODS => [qw(userid domain password)] FIELD_METHODS supports filters as specified by CGI::Application::Plugin::Authentication::Driver METHODS verify_credentials This method will test the provided credentials against the values found in the database, according to the Driver configuration. SEE ALSO CGI::Application::Plugin::Authentication::Driver, CGI::Application::Plugin::Authentication, perl(1) AUTHOR Shawn Sorichetti, "" BUGS Please report any bugs or feature requests to "bug-cgi-application-plugin-authentication-driver-cdbi@rt.cpan.org", or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ACKNOWLEDGEMENTS Special thanks to Cees Hek for writing CGI::Application::Plugin::Authentication and his assistance in writing this module. COPYRIGHT & LICENSE Copyright 2005 Shawn Sorichetti, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/0000755000076500007650000000000010326301135024366 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/00-load.t0000644000076500007650000000042010310350615025703 0ustar ssorichessoriche00000000000000#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'CGI::Application::Plugin::Authentication::Driver::CDBI' ); } diag( "Testing CGI::Application::Plugin::Authentication::Driver::CDBI $CGI::Application::Plugin::Authentication::Driver::CDBI::VERSION, Perl $], $^X" ); CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/authenticate.t0000644000076500007650000000315310324532417027242 0ustar ssorichessoriche00000000000000#!/usr/bin/perl use Test::More; use lib 't/lib'; eval "use CGI::Application::Plugin::Session"; plan skip_all => "CGI::Application::Plugin::Session required for this test" if $@; eval "use DBD::SQLite"; plan skip_all => "DBD::SQLite required for this test" if $@; plan tests => 8; use strict; use warnings; use CGI (); use TestAppAuthenticate; use TestUsers; use File::Path; mkpath(['t/db']); TestUsers->setuptables; $ENV{CGI_APP_RETURN_ONLY} = 1; # Missing Credentials my $query = CGI->new( { auth_username => 'user1', rm => 'two' } ); my $cgiapp = TestAppAuthenticate->new( QUERY => $query ); my $results = $cgiapp->run; ok(!$cgiapp->authen->is_authenticated,'missing credentials - login failure'); is( $cgiapp->authen->username, undef, 'missing credentials - username not set' ); # Successful Login $query = CGI->new( { auth_username => 'user1', auth_password => '123', rm => 'two' } ); $cgiapp = TestAppAuthenticate->new( QUERY => $query ); $results = $cgiapp->run; ok($cgiapp->authen->is_authenticated,'successful login'); is( $cgiapp->authen->username, 'user1', 'successful login - username set' ); is( $cgiapp->authen->login_attempts, 0, "successful login - failed login count" ); # Bad user or password $query = CGI->new( { auth_username => 'user2', auth_password => '123', rm => 'two' } ); $cgiapp = TestAppAuthenticate->new( QUERY => $query ); $results = $cgiapp->run; ok(!$cgiapp->authen->is_authenticated,'login failure'); is( $cgiapp->authen->username, undef, "login failure - username not set" ); is( $cgiapp->authen->login_attempts, 1, "login failure - failed login count" ); END { rmtree(['t/db']); } CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/authenticate_crypt.t0000644000076500007650000000166510324536144030472 0ustar ssorichessoriche00000000000000#!/usr/bin/perl use Test::More; use lib 't/lib'; eval "use CGI::Application::Plugin::Session"; plan skip_all => "CGI::Application::Plugin::Session required for this test" if $@; eval "use DBD::SQLite"; plan skip_all => "DBD::SQLite required for this test" if $@; plan tests => 3; use strict; use warnings; use CGI (); use TestAppAuthcrypt; use TestUsers; use File::Path; mkpath(['t/db']); TestUsers->setuptables; $ENV{CGI_APP_RETURN_ONLY} = 1; my $query = CGI->new( { auth_username => 'usercrypt', auth_password => 'testpassword', rm => 'two' } ); my $cgiapp = TestAppAuthcrypt->new( QUERY => $query ); my $results = $cgiapp->run; ok( $cgiapp->authen->is_authenticated, 'successful login crypt' ); is( $cgiapp->authen->username, 'usercrypt', 'successful login crypt - username set' ); is( $cgiapp->authen->login_attempts, 0, "successful login crypt - failed login count" ); END { rmtree(['t/db']); } CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/authenticate_md5.t0000644000076500007650000000175010324542013030001 0ustar ssorichessoriche00000000000000#!/usr/bin/perl use Test::More; use lib 't/lib'; eval "use CGI::Application::Plugin::Session"; plan skip_all => "CGI::Application::Plugin::Session required for this test" if $@; eval "use Digest::MD5"; plan skip_all => "Digest::MD5 required for this test" if $@; eval "use DBD::SQLite"; plan skip_all => "DBD::SQLite required for this test" if $@; plan tests => 3; use strict; use warnings; use CGI (); use TestAppAuthMD5; use TestUsers; use File::Path; mkpath(['t/db']); TestUsers->setuptables; $ENV{CGI_APP_RETURN_ONLY} = 1; my $query = CGI->new( { auth_username => 'usermd5', auth_password => 'testpassword', rm => 'two' } ); my $cgiapp = TestAppAuthMD5->new( QUERY => $query ); my $results = $cgiapp->run; ok( $cgiapp->authen->is_authenticated, 'successful login MD5' ); is( $cgiapp->authen->username, 'usermd5', 'successful login MD5 - username set' ); is( $cgiapp->authen->login_attempts, 0, "successful login MD5 - failed login count" ); END { rmtree(['t/db']); } CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/0000755000076500007650000000000010326301135025134 5ustar ssorichessoriche00000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/TestAppAuthcrypt.pm0000644000076500007650000000113510325011157030757 0ustar ssorichessoriche00000000000000package TestAppAuthcrypt; use base qw(CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Authentication; my %config = ( DRIVER => [ 'CDBI', CLASS => 'TestUsers', FIELD_METHODS => [qw(user crypt:passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], STORE => 'Session', ); __PACKAGE__->authen->config(%config); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes( [ qw(one two) ]); $self->authen->protected_runmodes(qw(two)); } sub one { my $self = shift; } sub two { my $self = shift; } 1; CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/TestAppAuthenticate.pm0000644000076500007650000000110210325016530031404 0ustar ssorichessoriche00000000000000package TestAppAuthenticate; use base qw(CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Authentication; __PACKAGE__->authen->config( DRIVER => [ 'CDBI', CLASS => 'TestUsers', FIELD_METHODS => [qw(user passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], STORE => 'Session', ); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes([ qw(one two) ]); $self->authen->protected_runmodes(qw(two)); } sub one { my $self = shift; } sub two { my $self = shift; } 1; CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/TestAppAuthMD5.pm0000644000076500007650000000113210325011165030177 0ustar ssorichessoriche00000000000000package TestAppAuthMD5; use base qw(CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Authentication; my %config = ( DRIVER => [ 'CDBI', CLASS => 'TestUsers', FIELD_METHODS => [qw(user MD5:passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], STORE => 'Session', ); __PACKAGE__->authen->config(%config); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes([qw(one two)]); $self->authen->protected_runmodes(qw(two)); } sub one { my $self = shift; } sub two { my $self = shift; } 1; CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/TestAppAuthPlain.pm0000644000076500007650000000112410325016572030665 0ustar ssorichessoriche00000000000000package TestAppAuthPlain; use base qw(CGI::Application); use CGI::Application::Plugin::Session; use CGI::Application::Plugin::Authentication; my %config = ( DRIVER => [ 'CDBI', CLASS => 'TestUsers', FIELD_METHODS => [qw(user plain:passphrase)] ], CREDENTIALS => [qw(auth_username auth_password)], STORE => 'Session', ); __PACKAGE__->auth->config(%config); sub setup { my $self = shift; $self->start_mode('one'); $self->run_modes(qw(one two)); $self->auth->protected_runmodes(qw(two)); } sub one { my $self = shift; } sub two { my $self = shift; } 1; CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/lib/TestUsers.pm0000644000076500007650000000110210324544065027436 0ustar ssorichessoriche00000000000000package TestUsers; use base 'Class::DBI'; __PACKAGE__->connection('dbi:SQLite:t/db/users.db'); __PACKAGE__->table('users'); __PACKAGE__->columns( All => qw[user passphrase] ); sub setuptables { my $dbh=DBI->connect('dbi:SQLite:t/db/users.db'); { local $/="\n\n"; $dbh->do($_) for } } 1; __DATA__ CREATE TABLE users ( user varchar(16) PRIMARY KEY, passphrase varchar(25) ); INSERT INTO users VALUES ('user1','123'); INSERT INTO users VALUES ('usermd5','e16b2ab8d12314bf4efbd6203906ea6c'); INSERT INTO users VALUES ('usercrypt','111ukgxvMW4Lw'); CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/pod-coverage.t0000644000076500007650000000025410310350615027127 0ustar ssorichessoriche00000000000000#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); CGI-Application-Plugin-Authentication-Driver-CDBI-0.02/t/pod.t0000644000076500007650000000021410310350615025332 0ustar ssorichessoriche00000000000000#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok();