| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CAS::Apache::PublicForms; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1613
|
use warnings FATAL => 'all', NONFATAL => 'redefine'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
50
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
CAS::Apache::UserForms - The great new CAS::Apache::UserForms! |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.01 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
17
|
1
|
|
|
1
|
|
490
|
use Apache2::Const qw(OK SERVER_ERROR REDIRECT AUTH_REQUIRED); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use base qw(CAS::Apache); |
|
19
|
|
|
|
|
|
|
use CAS::Apache::Auth (); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Quick summary of what the module does. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Perhaps a little code snippet. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use CAS::Apache::UserForms; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $foo = CAS::Apache::UserForms->new(); |
|
30
|
|
|
|
|
|
|
... |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 EXPORT |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
A list of functions that can be exported. You can delete this section |
|
35
|
|
|
|
|
|
|
if you don't export anything, such as for a purely object-oriented module. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 function1 |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub handler { |
|
45
|
|
|
|
|
|
|
my $apache2 = shift; |
|
46
|
|
|
|
|
|
|
die unless ref $apache2; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $request = $apache2->uri(); |
|
49
|
|
|
|
|
|
|
die unless $request; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$request =~ m{/(\w+)$}; |
|
52
|
|
|
|
|
|
|
my $page = $1; |
|
53
|
|
|
|
|
|
|
unless ($page) { |
|
54
|
|
|
|
|
|
|
die "Unable to determine page requested in $request"; |
|
55
|
|
|
|
|
|
|
} # unless it's a CAS page |
|
56
|
|
|
|
|
|
|
my $CR_gen_response = \&{$page}; |
|
57
|
|
|
|
|
|
|
unless (defined &$CR_gen_response) { |
|
58
|
|
|
|
|
|
|
die "$page is not available through __PACKAGE__"; |
|
59
|
|
|
|
|
|
|
} # see if method is defined in this namespace |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# $r->unparsed_uri to find args |
|
62
|
|
|
|
|
|
|
$apache2->content_type('text/html'); |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my ($status, $html) = &$CR_gen_response($apache2); |
|
65
|
|
|
|
|
|
|
return $status unless $status == OK; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
print $html; |
|
68
|
|
|
|
|
|
|
# warn "HTML printed\n"; |
|
69
|
|
|
|
|
|
|
return OK; |
|
70
|
|
|
|
|
|
|
} # handler |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub login { |
|
74
|
|
|
|
|
|
|
my $apache2 = shift || die 'Request object required'; |
|
75
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
76
|
|
|
|
|
|
|
$cgi->param(-name => 'Password', -value => ''); # just in case |
|
77
|
|
|
|
|
|
|
my $message = shift || ''; |
|
78
|
|
|
|
|
|
|
warn "message = $message"; |
|
79
|
|
|
|
|
|
|
$message = qq{$message} if $message; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $base_cas_dir = $apache2->dir_config('CAS_BASE_URI') || ''; |
|
82
|
|
|
|
|
|
|
my $auth_page = "$base_cas_dir/public/authentication"; |
|
83
|
|
|
|
|
|
|
my %params = $cgi->Vars; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $html = $cgi->start_html("CAS default login page") |
|
86
|
|
|
|
|
|
|
. $cgi->h1("Please enter username and password:") . "\n" |
|
87
|
|
|
|
|
|
|
. $message . "\n" |
|
88
|
|
|
|
|
|
|
. $cgi->start_form(-action => $auth_page) . "\n" |
|
89
|
|
|
|
|
|
|
. "Username: " |
|
90
|
|
|
|
|
|
|
. $cgi->textfield(-name => 'Username', -default => $params{Username}) |
|
91
|
|
|
|
|
|
|
. "\n" . $cgi->p . "Password: " |
|
92
|
|
|
|
|
|
|
. $cgi->password_field('Password') . "\n" |
|
93
|
|
|
|
|
|
|
. $cgi->hidden('uri', $params{return}) . "\n" |
|
94
|
|
|
|
|
|
|
. $cgi->p . $cgi->submit(-value=>'Log in') . "\n" . $cgi->end_form |
|
95
|
|
|
|
|
|
|
. "\n" . $cgi->p . qq{} |
|
96
|
|
|
|
|
|
|
. qq{Forgot password? } |
|
97
|
|
|
|
|
|
|
. "Register" |
|
98
|
|
|
|
|
|
|
. $cgi->end_html; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return (OK, $html); |
|
101
|
|
|
|
|
|
|
} # login |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub logout { |
|
105
|
|
|
|
|
|
|
my $apache2 = shift; |
|
106
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $html = $cgi->start_html("Foo"); |
|
109
|
|
|
|
|
|
|
$html .= <
|
|
110
|
|
|
|
|
|
|
Bar |
|
111
|
|
|
|
|
|
|
HTML |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
$html .= $cgi->end_html; |
|
114
|
|
|
|
|
|
|
return (OK, $html); |
|
115
|
|
|
|
|
|
|
} # logout |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub authentication { |
|
119
|
|
|
|
|
|
|
my $apache2 = shift; |
|
120
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
121
|
|
|
|
|
|
|
my %params = $cgi->Vars; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $base_cas_dir = $apache2->dir_config('CAS_BASE_URI') || ''; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $auth = $apache2->dir_config('auth_object'); |
|
126
|
|
|
|
|
|
|
my $status = SERVER_ERROR; |
|
127
|
|
|
|
|
|
|
my $messages = ''; |
|
128
|
|
|
|
|
|
|
{ |
|
129
|
|
|
|
|
|
|
no strict 'refs'; |
|
130
|
|
|
|
|
|
|
$status = ${$auth}->authen($apache2, $params{Username}, $params{Password}); |
|
131
|
|
|
|
|
|
|
$messages = ${$auth}->messages; |
|
132
|
|
|
|
|
|
|
warn "messages = $messages"; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
if ($status and $status == AUTH_REQUIRED) { |
|
135
|
|
|
|
|
|
|
# should be yet another configuration variable?!? |
|
136
|
|
|
|
|
|
|
return login($apache2, $messages); |
|
137
|
|
|
|
|
|
|
} # if auth required |
|
138
|
|
|
|
|
|
|
elsif ($status != OK) { return $status } |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $welcome = $apache2->dir_config('CAS_WELCOME_PAGE') || ''; |
|
141
|
|
|
|
|
|
|
my $location = $params{uri} || $welcome || "$base_cas_dir/"; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$apache2->headers_out->set(Location => $location); |
|
144
|
|
|
|
|
|
|
$apache2->status(REDIRECT); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
return (REDIRECT,''); |
|
147
|
|
|
|
|
|
|
} # authentication |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub forgot_password { |
|
151
|
|
|
|
|
|
|
my $apache2 = shift; |
|
152
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $html = $cgi->start_html("Foo"); |
|
155
|
|
|
|
|
|
|
$html .= <
|
|
156
|
|
|
|
|
|
|
Bar |
|
157
|
|
|
|
|
|
|
HTML |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$html .= $cgi->end_html; |
|
160
|
|
|
|
|
|
|
return (OK, $html) |
|
161
|
|
|
|
|
|
|
} # forgot_password |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub new_user { |
|
165
|
|
|
|
|
|
|
my $apache2 = shift; |
|
166
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $html = $cgi->start_html("Foo"); |
|
169
|
|
|
|
|
|
|
$html .= <
|
|
170
|
|
|
|
|
|
|
Bar |
|
171
|
|
|
|
|
|
|
HTML |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$html .= $cgi->end_html; |
|
174
|
|
|
|
|
|
|
return (OK, $html) |
|
175
|
|
|
|
|
|
|
} # new_user |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub contact { |
|
179
|
|
|
|
|
|
|
my $apache2 = shift; |
|
180
|
|
|
|
|
|
|
my $cgi = CGI->new; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
my $html = $cgi->start_html("Foo"); |
|
183
|
|
|
|
|
|
|
$html .= <
|
|
184
|
|
|
|
|
|
|
Bar |
|
185
|
|
|
|
|
|
|
HTML |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
$html .= $cgi->end_html; |
|
188
|
|
|
|
|
|
|
return (OK, $html) |
|
189
|
|
|
|
|
|
|
} # contact |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Sean P. Quinlan, C<< >> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 BUGS |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
200
|
|
|
|
|
|
|
C, or through the web interface at |
|
201
|
|
|
|
|
|
|
L. |
|
202
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
203
|
|
|
|
|
|
|
your bug as I make changes. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 SUPPORT |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
perldoc CAS::Apache |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
You can also look for information at: |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=over 4 |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
L |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
L |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * Search CPAN |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=back |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Copyright 2006 Sean P. Quinlan, all rights reserved. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
240
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=cut |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
1; # End of CAS::Apache::UserForms |