File Coverage

blib/lib/CGI/Application/Plugin/Authentication/Driver/HTPasswd.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package CGI::Application::Plugin::Authentication::Driver::HTPasswd;
2              
3 1     1   5 use strict;
  1         2  
  1         31  
4 1     1   4 use warnings;
  1         2  
  1         40  
5             our $VERSION = '0.20';
6              
7 1     1   37 use base qw(CGI::Application::Plugin::Authentication::Driver);
  1         2  
  1         1195  
8 1     1   8 use Apache::Htpasswd;
  1         2  
  1         322  
9              
10             =head1 NAME
11              
12             CGI::Application::Plugin::Authentication::Driver::HTPasswd - HTPasswd
13             Authentication driver
14              
15             =head1 VERSION
16              
17             This document describes CGI::Application::Plugin::Authentication::Driver::HTPasswd version 0.20
18              
19             =head1 SYNOPSIS
20              
21             use base qw(CGI::Application);
22             use CGI::Application::Plugin::Authentication;
23              
24             __PACKAGE__->authen->config(
25             DRIVER => ['HTPasswd', '/etc/apache/htpasswd', '/etc/apache/otherhtpasswd']
26             );
27              
28             =head1 DESCRIPTION
29              
30             This Driver allows you to authenticate against an htpasswd file. For
31             information on the format of the htpasswd file, see the documentation for the
32             Apache webserver. This driver requires that the L module is
33             installed.
34              
35              
36             =head1 METHODS
37              
38             =head2 verify_credentials
39              
40             This method will test the provided credentials against the htpasswd file(s)
41             defined in the DRIVER config.
42              
43             =cut
44              
45             sub verify_credentials {
46 16     16 1 28 my $self = shift;
47 16         35 my ( $username, $password ) = @_;
48              
49             # verify that all the options are OK
50 16         75 my @files = $self->options;
51 16 100       65 die "The HTPasswd driver requires at least one htpasswd file"
52             unless @files;
53              
54 15         42 foreach my $file (@files) {
55 26         2250 my $htpasswd = Apache::Htpasswd->new(
56             { passwdFile => $file,
57             ReadOnly => 1,
58             }
59             );
60 26 100       2381 return $username
61             if $htpasswd->htCheckPassword( $username, $password );
62             }
63 10         3419 return;
64             }
65              
66             =head1 SEE ALSO
67              
68             L,
69             L, perl(1)
70              
71              
72             =head1 LICENCE AND COPYRIGHT
73              
74             Copyright (c) 2005, SiteSuite. All rights reserved.
75              
76             This module is free software; you can redistribute it and/or modify it under
77             the same terms as Perl itself.
78              
79              
80             =head1 DISCLAIMER OF WARRANTY
81              
82             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
83             SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
84             STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
85             SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
86             INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
87             FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
88             PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE,
89             YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
90              
91             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
92             COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
93             SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES,
94             INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
95             OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO
96             LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
97             THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE),
98             EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
99             DAMAGES.
100              
101             =cut
102              
103             1;