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