Authentication::Credential::Password
/;
- __PACKAGE__->config->{authentication}{htpasswd} = "...";
+ __PACKAGE__->config->{authentication}{htpasswd} = "passwdfile";
sub login : Global {
my ( $self, $c ) = @_;
=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
=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
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 {
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
use strict;
use warnings;
-use Test::More 'no_plan';
-use Path::Class;
+use Test::More tests => 19;
use File::Temp qw/tempfile/;
$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" );
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");
plan tests => 12;
}
-use Path::Class;
-
use File::Temp qw/tempfile/;
my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
$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" );