prepare for release of C::P::Authentication::Store::Htpasswd
David Kamholz [Sun, 27 Nov 2005 21:56:00 +0000 (21:56 +0000)]
lib/Catalyst/Plugin/Authentication/Store/Htpasswd.pm
lib/Catalyst/Plugin/Authentication/Store/Htpasswd/Backend.pm
lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm
t/backend.t
t/backend_md5.t

index 428e9ba..6e92e1e 100644 (file)
@@ -38,7 +38,7 @@ database in C<<$c->config>>.
       Authentication::Credential::Password
       /;
 
-    __PACKAGE__->config->{authentication}{htpasswd} = "...";
+    __PACKAGE__->config->{authentication}{htpasswd} = "passwdfile";
 
     sub login : Global {
         my ( $self, $c ) = @_;
@@ -48,29 +48,37 @@ database in C<<$c->config>>.
 
 =head1 DESCRIPTION
 
-This plugin uses C<Apache::Htpasswd> to let your application use C<.htpasswd>
+This plugin uses C<Authen::Htpasswd> to let your application use C<.htpasswd>
 files for it's authentication storage.
 
 =head1 METHODS
 
-=over 4
-
-=item setup
+=head2 setup
 
 This method will popultate C<< $c->config->{authentication}{store} >> so that
 L<Catalyst::Plugin::Authentication/default_auth_store> can use it.
 
-=back
-
 =head1 CONFIGURATION
 
-=over 4
-
-=item $c->config->{authentication}{htpasswd}
+=head2 $c->config->{authentication}{htpasswd}
 
 The path to the htpasswd file.
 
-=back
+=head1 AUTHORS
+
+Yuval Kogman C<nothingmuch@woobling.org>
+
+David Kamholz C<dkamholz@cpan.org>
+
+=head1 SEE ALSO
+
+L<Authen::Htpasswd>.
+
+=head1 COPYRIGHT & LICNESE
+
+       Copyright (c) 2005 the aforementioned authors. All rights
+       reserved. This program is free software; you can redistribute
+       it and/or modify it under the same terms as Perl itself.
 
 =cut
 
index c5213b0..fa825ca 100644 (file)
@@ -79,25 +79,27 @@ Otherwise, this lets you create a store manually.
 
 =head1 METHODS
 
-=over 4
-
-=item new $hash_ref
+=head2 new $hash_ref
 
 Constructs a new store object, which uses the supplied hash ref as it's backing
 structure.
 
-=item get_user $id
+=head2 get_user $id
 
 Keys the hash by $id and returns the value.
 
 If the return value is unblessed it will be blessed as
 L<Catalyst::Plugin::Authentication::User::Hash>.
 
-=item user_supports
+=head2 user_supports
 
 Chooses a random user from the hash and delegates to it.
 
-=back
+=head1 COPYRIGHT & LICNESE
+
+       Copyright (c) 2005 the aforementioned authors. All rights
+       reserved. This program is free software; you can redistribute
+       it and/or modify it under the same terms as Perl itself.
 
 =cut
 
index f018026..42582d6 100644 (file)
@@ -37,7 +37,8 @@ sub check_password {
 
 sub roles {
        my $self = shift;
-       split( /,/, $self->user->extra_info );
+       my $field = $self->user->extra_info->[0];
+       return defined $field ? split /,/, $field : ();
 }
 
 sub for_session {
@@ -66,11 +67,39 @@ __END__
 Catalyst::Plugin::Authentication::Store::Htpasswd::User - A user object
 representing an entry in an htpasswd file.
 
-=head1 SYNOPSIS
+=head1 DESCRIPTION
 
-       use Catalyst::Plugin::Authentication::Store::Htpasswd::User;
+This object wraps an L<Authen::Htpasswd::User> object. An instance of it will be returned
+by C<< $c->user >> when using L<Catalyst::Plugin::Authentication::Store::Htpasswd>. Methods 
+not defined in this module are passed through to the L<Authen::Htpasswd::User> object. The
+object stringifies to the username.
 
-=head1 DESCRIPTION
+=head1 METHODS
+
+=head2 new($store,$user)
+
+Creates a new object from a store object, normally an instance of 
+L<Catalyst::Plugin::Authentication::Store::Htpasswd::Backend>, and a user object,
+normally an instance of L<Authen::Htpasswd::User>.
+
+=head2 id
+
+Returns the username.
+
+=head2 check_password($password)
+
+Returns whether the password is valid.
+
+=head2 roles
+
+Returns an array of roles, which is extracted from a comma-separated list in the
+third field of the htpasswd file.
+
+=head1 COPYRIGHT & LICNESE
+
+       Copyright (c) 2005 the aforementioned authors. All rights
+       reserved. This program is free software; you can redistribute
+       it and/or modify it under the same terms as Perl itself.
 
 =cut
 
index 2eb77ca..9fe0d0e 100644 (file)
@@ -3,8 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More 'no_plan';
-use Path::Class;
+use Test::More tests => 19;
 
 use File::Temp qw/tempfile/;
 
@@ -16,14 +15,12 @@ my $passwd = Authen::Htpasswd->new($tmp);
 
 $passwd->add_user("user", "s3cr3t");
 
-
 can_ok($m, "new");
 isa_ok(my $o = $m->new( $passwd ), $m);
 
 can_ok($m, "file");
 isa_ok( $o->file, "Authen::Htpasswd");
 
-
 can_ok( $m, "user_supports");
 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
 
@@ -37,7 +34,6 @@ ok( $u->supports(qw/password self_check/), "htpasswd users check their own passw
 can_ok( $u, "check_password");
 ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
 
-
 ok( $m->user_supports(qw/session/), "user_supports session");
 
 is( $u->store, $o, "can get store");
index c6f524a..61a5fbb 100644 (file)
@@ -11,8 +11,6 @@ BEGIN {
        plan tests => 12;
 }
 
-use Path::Class;
-
 use File::Temp qw/tempfile/;
 
 my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
@@ -23,14 +21,12 @@ my $passwd = Authen::Htpasswd->new($tmp, { encrypt_hash => 'md5' });
 
 $passwd->add_user("user", "s3cr3t");
 
-
 can_ok($m, "new");
 isa_ok(my $o = $m->new( $passwd ), $m);
 
 can_ok($m, "file");
 isa_ok( $o->file, "Authen::Htpasswd");
 
-
 can_ok( $m, "user_supports");
 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );