File Coverage

blib/lib/PlugAuth/Plugin/AuthenSimple.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 36 40 90.0


line stmt bran cond sub pod time code
1             package PlugAuth::Plugin::AuthenSimple;
2              
3 1     1   489631 use strict;
  1         5  
  1         50  
4 1     1   8 use warnings;
  1         4  
  1         46  
5 1     1   343 use Authen::Simple;
  1         392  
  1         43  
6 1     1   11 use Role::Tiny::With;
  1         3  
  1         377  
7              
8             with 'PlugAuth::Role::Plugin';
9             with 'PlugAuth::Role::Auth';
10              
11             # ABSTRACT: AuthenSimple plugin for PlugAuth
12             our $VERSION = '0.03'; # VERSION
13              
14              
15             sub init
16             {
17 1     1 0 60 my($self) = @_;
18            
19 1         5 my $config_list = $self->plugin_config;
20 1 50       10 $config_list = [ $config_list ] unless ref($config_list) eq 'ARRAY';
21            
22 1         3 my @simple_list;
23 1         4 foreach my $item (@$config_list)
24             {
25 2         192 while(my($class, $config) = each %$item)
26             {
27 2         152 eval qq{ require $class };
28 2 50       12 die $@ if $@;
29 2         30 push @simple_list, $class->new(%$config);
30             }
31             }
32            
33 1         90 $self->{simple} = Authen::Simple->new(@simple_list);
34 1         39 $self;
35             }
36              
37             sub check_credentials
38             {
39 3     3 0 92606 my($self, $user, $pass) = @_;
40 3 100       21 return 1 if $self->{simple}->authenticate($user, $pass);
41 1         162 $self->deligate_check_credentials($user, $pass);
42             }
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             PlugAuth::Plugin::AuthenSimple - AuthenSimple plugin for PlugAuth
55              
56             =head1 VERSION
57              
58             version 0.03
59              
60             =head1 SYNOPSIS
61              
62             PlugAuth.conf:
63              
64             ---
65             plugin:
66             - PlugAuth::Plugin::AuthenSimple:
67             - Authen::Simple::PAM:
68             service: login
69             - Authen::Simple::SMB:
70             domain: DOMAIN
71             pdc: PDC
72              
73             =head1 DESCRIPTION
74              
75             This plugin allows any L<Authen::Simple> implementation to be used as an
76             authentication mechanism for L<PlugAuth>. Because L<Authen::Simple>
77             does not provide a user list, neither does this plugin, so you will need
78             to maintain a list of users, perhaps using the
79             L<PlugAuth::Plugin::FlatUserList> plugin.
80              
81             =head1 SEE ALSO
82              
83             L<PlugAuth>, L<Authen::Simple>
84              
85             =head1 AUTHOR
86              
87             Graham Ollis <plicease@cpan.org>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is copyright (c) 2013 by Graham Ollis.
92              
93             This is free software; you can redistribute it and/or modify it under
94             the same terms as the Perl 5 programming language system itself.
95              
96             =cut