blib/lib/CGI/Application/Plugin/Authentication/Display.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 4 / 4 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 16 / 16 Podpod 100% 11 / 11 totaltotal 100% 80 / 80 CC 5 SCAR 4.1
CC
5
Cov
100%
login_title
3.0
logout_form
2.0
enforce_protection
2.0
CRAP 1.5
« blib/lib/CGI/Application/Plugin/Authentication/Store/Session.pm ↑ Summary blib/lib/CGI/Application/Plugin/Authentication/Driver/Filter/lc.pm »
1 package CGI::Application::Plugin::Authentication::Display;
2  
3 15 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 61 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 61 my $self = {};
11 61 $self->{cgiapp} = shift;
12 61 bless $self, $class;
13 61 return $self;
14 }
15  
16 sub _cgiapp {
17 692 ▶ my $self = shift;
Subroutine _cgiapp: called CC=1 SCAR=0.0
18 692 return $self->{cgiapp};
19 }
20  
21 sub login_box {
22 1 ▶ my $self = shift;
Subroutine login_box: called CC=1 SCAR=0.0
Pod documented
23 1 croak "not implemented in base class";
24 }
25  
26 sub logout_form {
27 4 ▶ my $self = shift;
Subroutine logout_form: called CC=2 SCAR=6.9
Pod documented
28 4 ▶ return '<a id="authen_logout_link" href="?authen_logout=1">Logout</a>'
Branch: 1 branch
BranchTrueFalseTotal
if $self->_cgiapp->authen->is_authenticated 1 3 4
29 if $self->_cgiapp->authen->is_authenticated;
30 3 return '';
31 }
32  
33 sub enforce_protection {
34 3 ▶ my $self = shift;
Subroutine enforce_protection: called CC=2 SCAR=6.9
Pod documented
35 3 ▶ croak "Attempt to bypass authentication on protected template"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_cgiapp->authen->is_authenticated 2 1 3
36 if !$self->_cgiapp->authen->is_authenticated;
37 1 return "<!-- AUTHENTICATED -->\n";
38 }
39  
40 sub is_authenticated {
41 4 ▶ my $self = shift;
Subroutine is_authenticated: called CC=1 SCAR=0.0
Pod documented
42 4 return $self->_cgiapp->authen->is_authenticated;
43 }
44  
45 sub username {
46 3 ▶ my $self = shift;
Subroutine username: called CC=1 SCAR=0.0
Pod documented
47 3 return $self->_cgiapp->authen->username;
48 }
49  
50 sub last_login {
51 3 ▶ my $self = shift;
Subroutine last_login: called CC=1 SCAR=0.0
Pod documented
52 3 return $self->_cgiapp->authen->last_login;
53 }
54  
55 sub last_access {
56 3 ▶ my $self = shift;
Subroutine last_access: called CC=1 SCAR=0.0
Pod documented
57 3 return $self->_cgiapp->authen->last_access;
58 }
59  
60 sub is_login_timeout {
61 3 ▶ my $self = shift;
Subroutine is_login_timeout: called CC=1 SCAR=0.0
Pod documented
62 3 return $self->_cgiapp->authen->is_login_timeout;
63 }
64  
65 sub login_attempts {
66 3 ▶ my $self = shift;
Subroutine login_attempts: called CC=1 SCAR=0.0
Pod documented
67 3 return $self->_cgiapp->authen->login_attempts;
68 }
69  
70 sub login_title {
71 62 ▶ my $self = shift;
Subroutine login_title: called CC=3 SCAR=11.0
Pod documented
72 62 ▶ my $login_options = $self->_cgiapp->authen->_config->{LOGIN_FORM} || {};
Condition100%2/2
$self->_cgiapp->authen->_config->{'LOGIN_FORM'} || {}
l!l
2042
MC/DC100%1/1
$self->_cgiapp->authen->_config->{'LOGIN_FORM'} || {}
$self->_cgiapp->authen->_config->{'LOGIN_FORM'}
Truth table100%2/2
A
A= $self->_cgiapp->authen->_config->{'LOGIN_FORM'}
Aresult
11
00
73 62 ▶ return $login_options->{TITLE} || 'Sign In';
Condition100%2/2
$login_options->{'TITLE'} || 'Sign In'
l!l
161
MC/DC100%1/1
$login_options->{'TITLE'} || 'Sign In'
$login_options->{'TITLE'}
Truth table100%2/2
A
A= $login_options->{'TITLE'}
Aresult
11
00
74 }
75  
76  
77 15 1;
78  
79 =head1 NAME
80  
81 CGI::Application::Plugin::Authentication::Display - Generate bits of HTML needed for authentication
82  
83 =head1 SYNOPSIS
84  
85 =head1 DESCRIPTION
86  
87 The purpose of this code is to keep display code away from the back-end of
88 authentication management. It is an abstract base class and must be used
89 in conjunction with derived classes. Those derived classes can be used
90 in an number of ways:
91  
92 =over
93  
94 =item
95  
96 The subclass L<CGI::Application::Plugin::Authentication::Display::Classic>
97 is provided to ensure backwards compatibility with the old code. It has
98 the advantage of working out of the box but still retaining flexibility.
99  
100 =item
101  
102 The subclass L<CGI::Application::Plugin::Authentication::Display::Basic>
103 is provided to ensure XHTML compliance and to leave styling to CSS style-sheets.
104  
105 =item
106  
107 You can handle all the HTML side yourself in which case this code is not even loaded.
108  
109 =item
110  
111 You can use derived classes in templates that have dot support, which keeps
112 the display code close to the templates. This has other advantages. For example
113 one can use the C<enforce_protection> method to mark a template as being
114 only viewable after authentication. A number of other methods can be called
115 from the template that provide information about the authentication status.
116  
117 =back
118  
119 =head1 METHODS
120  
121 =head2 new
122  
123 The constructor must be passed the L<CGI::Application> object as the first
124 non-object argument. This allows derived modules to access the
125 authentication information.
126  
127 =head2 login_box
128  
129 This method will return the HTML for a login box that can be
130 embedded into another page. This is the same login box that is used
131 in the default authen_login runmode that the plugin provides.
132  
133 This function is not implemented in this module. One must use a derived class
134 with an appropriate implementation of this function.
135  
136 =head2 logout_form
137  
138 This returns the simple bit of HTML need to have a logout button. The form
139 has '/?authen_logout=1' as the action but of course this can be changed in
140 derived modules.
141  
142 =head2 enforce_protection
143  
144 This method is useful when the class is being used in templates to mark a
145 certain template as for authenticated eyes only. So in
146 L<HTML::Template::Plugin::Dot> one might have
147  
148 <TMPL_VAR NAME="authen.enforce_protection">
149
150 and one must set C<authen> to one of these objects via the
151 C<HTML::Template::param> method. If authenticated it will resolve to a
152 simple string, otherwise it will croak.
153  
154 =head2 login_title
155  
156 This returns the I<TITLE> parameter from the I<LOGIN_FORM> section of the config.
157  
158 =head2 is_authenticated
159  
160 =head2 username
161  
162 =head2 last_login
163  
164 =head2 last_access
165  
166 =head2 is_login_timeout
167  
168 =head2 login_attempts
169  
170 These methods all provide access to the cognate methods on the authentication
171 object. They are provided as templates might find them expressive.
172  
173 =head1 BUGS
174  
175 This is alpha software and as such, the features and interface
176 are subject to change. So please check the Changes file when upgrading.
177  
178 =head1 SEE ALSO
179  
180 L<CGI::Application>, perl(1)
181  
182 =head1 AUTHOR
183  
184 Author: Cees Hek <ceeshek@gmail.com>; Co-maintainer: Nicholas Bamber <nicholas@periapt.co.uk>.
185  
186 =head1 CREDITS
187  
188 Thanks to SiteSuite (http://www.sitesuite.com.au) for funding the
189 development of this plugin and for releasing it to the world.
190  
191 Thanks to Christian Walde for suggesting changes to fix the incompatibility
192 with L<CGI::Application::Plugin::ActionDispatch> and for help with github.
193  
194 =head1 LICENCE AND COPYRIGHT
195  
196 Copyright (c) 2005, SiteSuite. All rights reserved.
197 Copyright (c) 2010, Nicholas Bamber. All rights reserved.
198  
199 This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
200  
201 =head1 DISCLAIMER OF WARRANTY
202  
203 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.
204  
205 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.
206  
207 =cut
208  
209 15 1;
« blib/lib/CGI/Application/Plugin/Authentication/Store/Session.pm ↑ Summary blib/lib/CGI/Application/Plugin/Authentication/Driver/Filter/lc.pm »