3 package Catalyst::Authentication::Store::Htpasswd;
4 use base qw/Class::Accessor::Fast/;
9 use Catalyst::Authentication::Store::Htpasswd::User;
10 use Scalar::Util qw/blessed/;
12 our $VERSION = '1.001';
14 BEGIN { __PACKAGE__->mk_accessors(qw/file/) }
17 my ($class, $config, $app, $realm) = @_;
19 my $file = delete $config->{file};
20 unless (ref $file) { # FIXME - file not in app..
21 my $filename = $app->path_to($file)->stringify;
22 die("Cannot find htpasswd file: $filename\n") unless (-r $filename);
23 $file = Authen::Htpasswd->new($filename);
25 $config->{file} = $file;
27 bless { %$config }, $class;
31 my ($self, $authinfo, $c) = @_;
32 # FIXME - change username
33 my $htpasswd_user = $self->file->lookup_user($authinfo->{username});
34 Catalyst::Authentication::Store::Htpasswd::User->new( $self, $htpasswd_user );
40 # this can work as a class method
41 Catalyst::Authentication::Store::Htpasswd::User->supports(@_);
45 my ( $self, $c, $id ) = @_;
46 $self->find_user( { username => $id } );
57 Catalyst::Authentication::Store::Htpasswd - L<Authen::Htpasswd> based
58 user storage/authentication.
68 default_realm => 'test',
73 password_field => 'password',
74 password_type => 'self_check',
86 my ( $self, $c ) = @_;
88 $c->authenticate({ username => $c->req->param("login"), password => $c->req->param("password") });
93 This plugin uses C<Authen::Htpasswd> to let your application use C<.htpasswd>
94 files for it's authentication storage.
100 Simple constructor, dies if the htpassword file can't be found
104 Looks up the user, and returns a Catalyst::Authentication::Store::Htpasswd::User object.
108 Delegates to L<Catalyst::Authentication::Store::Htpasswd::User->user_supports|Catalyst::Authentication::Store::Htpasswd::User#user_supports>
112 Delegates the user lookup to C< find_user >
118 The path to the htpasswd file, this is taken from the application root.
122 Yuval Kogman C<nothingmuch@woobling.org>
124 David Kamholz C<dkamholz@cpan.org>
126 Tomas Doran C<bobtfish@bobtfish.net>
132 =head1 COPYRIGHT & LICENSE
134 Copyright (c) 2005-2008 the aforementioned authors. All rights
135 reserved. This program is free software; you can redistribute
136 it and/or modify it under the same terms as Perl itself.