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              
3 2     2   1331 use strict;
  2         70  
  2         86  
4 2     2   12 use warnings;
  2         42  
  2         110  
5             our $VERSION = '0.20';
6              
7 2     2   11 use base qw(CGI::Application::Plugin::Authentication::Driver);
  2         4  
  2         1001  
8              
9 2     2   14 use Carp;
  2         4  
  2         374  
10 2     2   14 use UNIVERSAL::require;
  2         4  
  2         10  
11              
12             =head1 NAME
13              
14             CGI::Application::Plugin::Authentication::Driver::Authen::Simple - Authen::Simple Authentication driver
15              
16             =head1 VERSION
17              
18             This document describes CGI::Application::Plugin::Authentication::Driver::Authen::Simple version 0.20
19              
20             =head1 SYNOPSIS
21              
22             use base qw(CGI::Application);
23             use CGI::Application::Plugin::Authentication;
24              
25             __PACKAGE__->authen->config(
26             DRIVER => [ 'Authen::Simple::Kerberos', realm => 'REALM.COMPANY.COM' ],
27             );
28              
29             =head1 DESCRIPTION
30              
31             This driver allows you to use any modules that following the Authen::Simple
32             API. All options that you provide will be passed on to the given Authen::Simple
33             module.
34              
35             =head1 EXAMPLE
36              
37             __PACKAGE__->authen->config(
38             DRIVER => [ 'Authen::Simple::CDBI', class => 'MyApp::Model::User' ],
39             );
40              
41              
42             =head1 METHODS
43              
44             =head2 verify_credentials
45              
46             This method will test the provided credentials against the Authen::Simple module
47             that was configured.
48              
49             =cut
50              
51             sub verify_credentials {
52 2     2 1 3 my $self = shift;
53 2         5 my @creds = @_;
54 2         19 my @options = $self->options;
55 2         6 my $authen_class = shift @options;
56              
57 2 50 33     23 return undef unless defined $creds[0] && defined $creds[1];
58              
59 2 100       15 $authen_class->require || Carp::croak("The $authen_class module is not installed");
60              
61 1         480 my $authen_obj = $authen_class->new(@options);
62 1 50       34 croak("Failed to create $authen_class instance") if !defined $authen_obj;
63              
64 0 0         return $authen_obj->authenticate(@creds) ? $creds[0] : undef;
65             }
66              
67              
68             =head1 SEE ALSO
69              
70             L, L, perl(1)
71              
72              
73             =head1 LICENCE AND COPYRIGHT
74              
75             Copyright (c) 2006, SiteSuite. All rights reserved.
76              
77             This module is free software; you can redistribute it and/or modify it under 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 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.
83              
84             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.
85              
86             =cut
87              
88             1;