File Coverage

blib/lib/CGI/Application/Plugin/Authentication/Driver/Authen/Simple.pm
Criterion Covered Total %
statement 23 24 95.8
branch 4 8 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 1 1 100.0
total 35 42 83.3


line stmt bran cond sub pod time code
1             package CGI::Application::Plugin::Authentication::Driver::Authen::Simple;
2             $CGI::Application::Plugin::Authentication::Driver::Authen::Simple::VERSION = '0.21';
3 2     2   553 use strict;
  2         25  
  2         49  
4 2     2   11 use warnings;
  2         3  
  2         54  
5              
6 2     2   6 use base qw(CGI::Application::Plugin::Authentication::Driver);
  2         2  
  2         445  
7              
8 2     2   8 use Carp;
  2         2  
  2         131  
9 2     2   8 use UNIVERSAL::require;
  2         2  
  2         6  
10              
11             =head1 NAME
12              
13             CGI::Application::Plugin::Authentication::Driver::Authen::Simple - Authen::Simple Authentication driver
14              
15             =head1 SYNOPSIS
16              
17             use base qw(CGI::Application);
18             use CGI::Application::Plugin::Authentication;
19              
20             __PACKAGE__->authen->config(
21             DRIVER => [ 'Authen::Simple::Kerberos', realm => 'REALM.COMPANY.COM' ],
22             );
23              
24             =head1 DESCRIPTION
25              
26             This driver allows you to use any modules that following the Authen::Simple
27             API. All options that you provide will be passed on to the given Authen::Simple
28             module.
29              
30             =head1 EXAMPLE
31              
32             __PACKAGE__->authen->config(
33             DRIVER => [ 'Authen::Simple::CDBI', class => 'MyApp::Model::User' ],
34             );
35              
36              
37             =head1 METHODS
38              
39             =head2 verify_credentials
40              
41             This method will test the provided credentials against the Authen::Simple module
42             that was configured.
43              
44             =cut
45              
46             sub verify_credentials {
47 2     2 1 3 my $self = shift;
48 2         3 my @creds = @_;
49 2         14 my @options = $self->options;
50 2         3 my $authen_class = shift @options;
51              
52 2 50 33     18 return undef unless defined $creds[0] && defined $creds[1];
53              
54 2 100       9 $authen_class->require || Carp::croak("The $authen_class module is not installed");
55              
56 1         247 my $authen_obj = $authen_class->new(@options);
57 1 50       23 croak("Failed to create $authen_class instance") if !defined $authen_obj;
58              
59 0 0         return $authen_obj->authenticate(@creds) ? $creds[0] : undef;
60             }
61              
62              
63             =head1 SEE ALSO
64              
65             L, L, perl(1)
66              
67              
68             =head1 LICENCE AND COPYRIGHT
69              
70             Copyright (c) 2006, SiteSuite. All rights reserved.
71              
72             This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
73              
74              
75             =head1 DISCLAIMER OF WARRANTY
76              
77             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
78              
79             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
80              
81             =cut
82              
83             1;