CGI-Application-Plugin-Authentication-Driver-CDBI-0.03000755000765000024 011610501242 22007 5ustar00brianstaff000000000000Build.PL000444000765000024 322511610501242 23363 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03use strict; use warnings; use Module::Build; print <<'ADOPTME'; ------------------------------------------------------------------- ADOPT ME! ADOPT ME! ADOPT ME! ADOPT ME! ADOPT ME! ------------------------------------------------------------------- CGI::Application::Plugin::Authentication::Driver::CDBI This is a module looking for a home. If you are still using it, you might want to adopt it. Write to modules@perl.org to ask to become its owner! Otherwise, this module is unsupported. ------------------------------------------------------------------- ADOPT ME! ADOPT ME! ADOPT ME! ADOPT ME! ADOPT ME! ------------------------------------------------------------------- (I'll give you 5 seconds to think about that). ADOPTME sleep 5; my $builder = Module::Build->new( module_name => 'CGI::Application::Plugin::Authentication::Driver::CDBI', license => 'perl', create_readme => 1, configure_requires => { 'Module::Build' => 0.38 }, 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', 'CGI::Application::Plugin::Session' => '0', }, resources => { repository => 'https://github.com/briandfoy/CGI-Application-Plugin-Authentication-Driver-CDBI', }, add_to_cleanup => ['CGI-Application-Plugin-Authentication-Driver-CDBI-*'], ); $builder->create_build_script(); Changes000444000765000024 22511610501242 23337 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03Revision history for CGI-Application-Plugin-Authentication-Driver-CDBI 0.01 Date/time First version, released on an unsuspecting world. MANIFEST000444000765000024 55611610501242 23204 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03Build.PL Changes lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm 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 META.json META.json000444000765000024 227411610501242 23513 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03{ "abstract" : "Class::DBI Authentication Driver", "author" : [ "Shawn Sorichetti " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.38, CPAN::Meta::Converter version 2.110440", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "CGI-Application-Plugin-Authentication-Driver-CDBI", "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0.38" } }, "runtime" : { "requires" : { "CGI::Application::Plugin::Authentication" : "0.06", "CGI::Application::Plugin::Session" : 0, "Class::DBI" : 0, "DBD::SQLite" : 0, "Test::More" : 0 } } }, "provides" : { "CGI::Application::Plugin::Authentication::Driver::CDBI" : { "file" : "lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm", "version" : "0.03" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "0.03" } META.yml000444000765000024 143411610501242 23340 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03--- abstract: 'Class::DBI Authentication Driver' author: - 'Shawn Sorichetti ' build_requires: {} configure_requires: Module::Build: 0.38 dynamic_config: 1 generated_by: 'Module::Build version 0.38, CPAN::Meta::Converter version 2.110440' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: CGI-Application-Plugin-Authentication-Driver-CDBI provides: CGI::Application::Plugin::Authentication::Driver::CDBI: file: lib/CGI/Application/Plugin/Authentication/Driver/CDBI.pm version: 0.03 requires: CGI::Application::Plugin::Authentication: 0.06 CGI::Application::Plugin::Session: 0 Class::DBI: 0 DBD::SQLite: 0 Test::More: 0 resources: license: http://dev.perl.org/licenses/ version: 0.03 README000444000765000024 537411610501242 22756 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03NAME THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. CGI::Application::Plugin::Authentication::Driver::CDBI - Class::DBI Authentication Driver VERSION Version 0.03 THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. 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 THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. 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. lib000755000765000024 011610501242 22476 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03CGI000755000765000024 011610501242 23100 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/libApplication000755000765000024 011610501242 25343 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/lib/CGIPlugin000755000765000024 011610501242 26601 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/lib/CGI/ApplicationAuthentication000755000765000024 011610501242 31560 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/lib/CGI/Application/PluginDriver000755000765000024 011610501242 33013 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/lib/CGI/Application/Plugin/AuthenticationCDBI.pm000444000765000024 1125211610501242 34230 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/lib/CGI/Application/Plugin/Authentication/Driverpackage CGI::Application::Plugin::Authentication::Driver::CDBI; use warnings; use strict; use base 'CGI::Application::Plugin::Authentication::Driver'; =head1 NAME THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. CGI::Application::Plugin::Authentication::Driver::CDBI - Class::DBI Authentication Driver =head1 VERSION Version 0.03 THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. =cut our $VERSION = '0.03'; =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 THIS MODULE IS UNSUPPORTED! YOU CAN ADOPT IT IF YOU LIKE IT! WRITE TO modules@perl.org IF YOU WANT TO MAINTAIN IT. 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 t000755000765000024 011610501242 22173 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.0300-load.t000444000765000024 42011610501242 23625 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!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" ); authenticate.t000444000765000024 315311610501242 25175 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!/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']); } authenticate_crypt.t000444000765000024 166511610501242 26424 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!/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']); } authenticate_md5.t000444000765000024 175011610501242 25743 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!/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']); } pod-coverage.t000444000765000024 25411610501242 25051 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!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(); pod.t000444000765000024 21411610501242 23254 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t#!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(); lib000755000765000024 011610501242 22741 5ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/tTestAppAuthcrypt.pm000444000765000024 113511610501242 26720 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t/libpackage 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; TestAppAuthenticate.pm000444000765000024 110211610501242 27345 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t/libpackage 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; TestAppAuthMD5.pm000444000765000024 113211610501242 26141 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t/libpackage 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; TestAppAuthPlain.pm000444000765000024 112411610501242 26620 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t/libpackage 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; TestUsers.pm000444000765000024 110211610501242 25367 0ustar00brianstaff000000000000CGI-Application-Plugin-Authentication-Driver-CDBI-0.03/t/libpackage 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');