[Catalyst-commits] r8480 - / Catalyst-Helper-AuthDBIC/trunk
Catalyst-Helper-AuthDBIC/trunk/lib/Catalyst/Helper
Catalyst-Helper-AuthDBIC/trunk/script
Catalyst-Helper-AuthDBIC/trunk/t
zarquon at dev.catalyst.perl.org
zarquon at dev.catalyst.perl.org
Wed Oct 1 10:14:14 BST 2008
Author: zarquon
Date: 2008-10-01 10:14:13 +0100 (Wed, 01 Oct 2008)
New Revision: 8480
Added:
Catalyst-Helper-AuthDBIC/trunk/t/02-usage.t
Modified:
/
Catalyst-Helper-AuthDBIC/trunk/Changes
Catalyst-Helper-AuthDBIC/trunk/Makefile.PL
Catalyst-Helper-AuthDBIC/trunk/lib/Catalyst/Helper/AuthDBIC.pm
Catalyst-Helper-AuthDBIC/trunk/script/auth_bootstrap.pl
Log:
r14050 at zaphod: kd | 2008-09-24 18:52:08 +1000
http and password stores improved tests more robust encryption (not quite yet working)
Property changes on:
___________________________________________________________________
Name: svk:merge
- 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:13870
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
+ 1b129c88-ebf4-0310-add9-f09427935aba:/local/catalyst:4278
1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst:14050
3b9770f9-e80c-0410-a7de-cd203d167417:/local/catalyst:3514
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst:6909
Modified: Catalyst-Helper-AuthDBIC/trunk/Changes
===================================================================
--- Catalyst-Helper-AuthDBIC/trunk/Changes 2008-09-30 08:05:47 UTC (rev 8479)
+++ Catalyst-Helper-AuthDBIC/trunk/Changes 2008-10-01 09:14:13 UTC (rev 8480)
@@ -1,3 +1,6 @@
+0.06 September 24 2008
+ - Moved from DBIx::Class::DigestColumns to DBIx::Class::EncodedColumn
+ - Added option for password or http credentials.
0.05 Tue Sep 2 2008
- Bug fix for Multi::Level::App::Names
- Addition of model config to .conf file
Modified: Catalyst-Helper-AuthDBIC/trunk/Makefile.PL
===================================================================
--- Catalyst-Helper-AuthDBIC/trunk/Makefile.PL 2008-09-30 08:05:47 UTC (rev 8479)
+++ Catalyst-Helper-AuthDBIC/trunk/Makefile.PL 2008-10-01 09:14:13 UTC (rev 8480)
@@ -8,10 +8,12 @@
build_requires 'Catalyst::Runtime';
build_requires 'ok';
-requires 'DBIx::Class::DigestColumns';
-requires 'Digest::SHA1';
+requires 'DBIx::Class::EncodedColumn';
+requires 'Crypt::Eksblowfish::Bcrypt';
requires 'PPI';
requires 'DBIx::Class::Schema::Loader';
+build_requires 'Directory::Scratch';
+build_requires 'Test::Command';
# not real deps but the generated bits of app need them.
requires 'Catalyst::Plugin::Authentication';
@@ -19,7 +21,8 @@
requires 'Catalyst::Plugin::Session';
requires 'Catalyst::Plugin::Session::State::Cookie';
requires 'Catalyst::Plugin::Session::Store::FastMmap';
-requires 'Catalyst::Plugin::Authentication::Store::DBIC';
+requires 'Catalyst::Authentication::Store::DBIx::Class';
+requires 'Catalyst::Authentication::Credential::HTTP';
install_script glob('script/*.pl');
Modified: Catalyst-Helper-AuthDBIC/trunk/lib/Catalyst/Helper/AuthDBIC.pm
===================================================================
--- Catalyst-Helper-AuthDBIC/trunk/lib/Catalyst/Helper/AuthDBIC.pm 2008-09-30 08:05:47 UTC (rev 8479)
+++ Catalyst-Helper-AuthDBIC/trunk/lib/Catalyst/Helper/AuthDBIC.pm 2008-10-01 09:14:13 UTC (rev 8480)
@@ -2,7 +2,7 @@
use strict;
use warnings;
use Catalyst::Helper;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
use Carp;
use DBI;
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
@@ -91,9 +91,9 @@
map { $dbh->do($_) } @sql;
my $app_prefix = Catalyst::Utils::appprefix(app_name());
-
+
make_schema_at(app_name() . "::Auth::Schema",
- { components => ['DigestColumns'],
+ { components => ['EncodedColumn'],
dump_directory => 'lib' ,
},
["dbi:SQLite:dbname=db/auth.db", "",""]);
@@ -198,11 +198,22 @@
=cut
sub add_config {
+ my ($credential) = @_;
my ($module, $doc) = _get_ppi();
my $found = PPI::Find->new(\&_find_setup);
my ($setup) = $found->in($doc);
croak "unable to find __PACKAGE__->setup in $module\n" if !$setup;
- my $auth_doc_plain = Catalyst::Helper->get_file(__PACKAGE__, 'auth_conf');
+ my $auth_doc_plain;
+
+ if ( $credential eq 'http' ) {
+ warn "Configuring http credential\n";
+ $auth_doc_plain = Catalyst::Helper->get_file(__PACKAGE__, 'auth_conf_http');
+ }
+ elsif ( $credential eq 'password' ) {
+ warn "Configuring password (web based) authentication credential\n";
+ $auth_doc_plain = Catalyst::Helper->get_file(__PACKAGE__, 'auth_conf_passwd');
+ }
+
$auth_doc_plain =~ s/__MYSCHEMA__/Auth/msg;
my $auth_doc = PPI::Document->new(\$auth_doc_plain);
my $auth_conf = $auth_doc->find_first('PPI::Statement');
@@ -411,7 +422,7 @@
=cut
-__auth_conf__
+__auth_conf_http__
__PACKAGE__->config( authentication => {
'default_realm' => 'users',
'realms' => {
@@ -421,10 +432,32 @@
'user_class' => '__MYSCHEMA__::User',
'class' => 'DBIx::Class',
},
+ 'credential' => {
+ 'password_type' => 'hashed',
+ 'password_field' => 'password',
+ 'password_hash_type' => 'Eksblowfish::Bcrypt',
+ 'class' => 'HTTP',
+ 'type' => 'basic',
+ }
+ }
+ },
+});
+
+
+__auth_conf_password__
+ __PACKAGE__->config( authentication => {
+ 'default_realm' => 'users',
+ 'realms' => {
+ 'users' => {
+ 'store' => {
+ 'role_column' => 'role_text',
+ 'user_class' => '__MYSCHEMA__::User',
+ 'class' => 'DBIx::Class',
+ },
'credential' => {
'password_type' => 'hashed',
'password_field' => 'password',
- 'password_hash_type' => 'SHA-1',
+ 'password_hash_type' => 'Eksblowfish::Bcrypt',
'class' => 'Password'
}
}
@@ -432,12 +465,15 @@
});
__digest__
- __PACKAGE__->digestcolumns(
- columns => [qw/ password /],
- algorithm => 'SHA-1',
- encoding => 'base64',
- auto => 1,
-);
+__PACKAGE__->add_columns(
+ 'password' => {
+ data_type => 'CHAR',
+ size => 22,
+ encode_column => 1,
+ encode_class => 'Crypt::Eksblowfish::Bcrypt',
+ encode_args => { key_nul => 0, cost => 8 },
+ digest_check_method => 'check_password',
+ });
__requires__
requires 'Catalyst::Plugin::Authentication';
@@ -445,8 +481,10 @@
requires 'Catalyst::Plugin::Session';
requires 'Catalyst::Plugin::Session::State::Cookie';
requires 'Catalyst::Plugin::Session::Store::FastMmap';
-requires 'Catalyst::Plugin::Authentication::Store::DBIC';
-requires 'Digest::SHA1';
+requires 'Catalyst::Authentication::Store::DBIx::Class';
+requires 'Catalyst::Authentication::Credential::HTTP';
+requires 'Crypt::Eksblowfish::Bcrypt';
+requires 'DBIx::Class::EncodedColumn;
__login.tt__
<h1> Please login</h1>
[% IF c.stash.message != '' %] <h2 style='color:red'> [% c.stash.message %] </h2
Modified: Catalyst-Helper-AuthDBIC/trunk/script/auth_bootstrap.pl
===================================================================
--- Catalyst-Helper-AuthDBIC/trunk/script/auth_bootstrap.pl 2008-09-30 08:05:47 UTC (rev 8479)
+++ Catalyst-Helper-AuthDBIC/trunk/script/auth_bootstrap.pl 2008-10-01 09:14:13 UTC (rev 8480)
@@ -1,26 +1,43 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
use Catalyst::Helper::AuthDBIC;
+use Pod::Usage;
=head1 NAME
auth_bootstrap.pl
-=head1 Summary
+=head1 SYNOPSIS
-Run with no arguments in the root directory of a catalyst application
-to bootstrap a catalyst application. This uses
-Catalyst::Helper::AuthDBIC to do so. This is an experiemntal module,
-and you are urged to back up your application before using this
-script. At present there are no options to pass on to the script.
+ auth-bootstrap.pl -credential (http|password)
+Boostrap simple database backed authentication for a Catalyst
+application. The store argument is optional and defaults to http
+(basic) authentication. Use of the password option provides some
+basic html templates and (buggy - patches welcome) pass through login.
+
=cut
+
+use Getopt::Long;
+
+my $credential = '';
+my $help = undef;
+
+GetOptions ( "credential=s" => \$credential,
+ help => \$help);
+
+pod2usage(1) if ( $help || !$credential );
+
+if ($credential !~ /^(http|password)$/) {
+ die "Valid credentials are 'http' for basic auth or 'password' for web based auth";
+}
+
Catalyst::Helper::AuthDBIC::make_model();
-Catalyst::Helper::AuthDBIC::mk_auth_controller();
+Catalyst::Helper::AuthDBIC::mk_auth_controller() if $credential eq 'password';
Catalyst::Helper::AuthDBIC::add_plugins();
-Catalyst::Helper::AuthDBIC::add_config();
+Catalyst::Helper::AuthDBIC::add_config($credential);
Catalyst::Helper::AuthDBIC::write_templates();
Catalyst::Helper::AuthDBIC::update_makefile();
Catalyst::Helper::AuthDBIC::add_user_helper();
Added: Catalyst-Helper-AuthDBIC/trunk/t/02-usage.t
===================================================================
--- Catalyst-Helper-AuthDBIC/trunk/t/02-usage.t (rev 0)
+++ Catalyst-Helper-AuthDBIC/trunk/t/02-usage.t 2008-10-01 09:14:13 UTC (rev 8480)
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::Command qw/no_plan/;
+use Test::More;
+use Directory::Scratch;
+use FindBin qw/$Bin/;
+my $bootstrap = "$Bin/../script/auth_bootstrap.pl";
+
+use ok 'Catalyst::Helper::AuthDBIC';
+
+my $wdir = Directory::Scratch->new();
+
+chdir $wdir;
+exit_is_num ( 'catalyst.pl Test::App', 0 , 'test app');
+ok(chdir 'Test-App');
+exit_is_num ("/usr/bin/env perl $bootstrap -credential http", 0, 'auth bootstrap');
+exit_is_num( "/usr/bin/env perl script/test_app_auth_admin.pl -user fred -password wilma", 0 , "created user");
+undef $wdir;
Property changes on: Catalyst-Helper-AuthDBIC/trunk/t/02-usage.t
___________________________________________________________________
Name: svn:mime-type
+ text/script
More information about the Catalyst-commits
mailing list