| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Gantry::Control::C::AuthenBase; |
|
2
|
1
|
|
|
1
|
|
1680
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
51
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
33
|
|
|
83
|
use constant MP2 => ( |
|
5
|
|
|
|
|
|
|
exists $ENV{MOD_PERL_API_VERSION} and |
|
6
|
|
|
|
|
|
|
$ENV{MOD_PERL_API_VERSION} >= 2 |
|
7
|
1
|
|
|
1
|
|
4
|
); |
|
|
1
|
|
|
|
|
3
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# must explicitly import for mod_perl2 |
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
1
|
|
|
1
|
|
628
|
if (MP2) { |
|
12
|
|
|
|
|
|
|
require Gantry::Engine::MP20; |
|
13
|
|
|
|
|
|
|
Gantry::Engine::MP20->import(); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
###################################################################### |
|
18
|
|
|
|
|
|
|
# Main Execution Begins Here # |
|
19
|
|
|
|
|
|
|
###################################################################### |
|
20
|
|
|
|
|
|
|
sub handler : method { |
|
21
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $r ) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
my $user_model = $self->user_model(); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Check Exclude paths |
|
26
|
0
|
0
|
|
|
|
0
|
if ( $r->dir_config( 'exclude_path' ) ) { |
|
27
|
0
|
|
|
|
|
0
|
foreach my $p ( split( /\s*;\s*/, $r->dir_config( 'exclude_path' ) )) { |
|
28
|
0
|
0
|
|
|
|
0
|
if ( $r->path_info =~ /^$p$/ ) { |
|
29
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'OK' ) ); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
my ( $ret, $sent_pw ) = $r->get_basic_auth_pw; |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
0
|
if ( $ret != $self->status_const( 'OK' ) ) { |
|
37
|
|
|
|
|
|
|
# Force disconnect from database due to failure. |
|
38
|
0
|
|
|
|
|
0
|
$user_model->disconnect(); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'DECLINED' ) ); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $user = $r->user; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
0
|
0
|
|
|
0
|
unless ( defined $user && $user ) { |
|
46
|
0
|
|
|
|
|
0
|
$r->note_basic_auth_failure; |
|
47
|
0
|
|
|
|
|
0
|
$r->log_error(' [login failure: ', $self->remote_ip( $r ), ']', |
|
48
|
|
|
|
|
|
|
" user $user ($sent_pw) not found ", $r->uri ); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Force disconnect from database due to failure. |
|
51
|
0
|
|
|
|
|
0
|
$user_model->disconnect(); |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'HTTP_UNAUTHORIZED' ) ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# get user row for the user_id |
|
57
|
0
|
|
|
|
|
0
|
my @user_row = $user_model->search( |
|
58
|
|
|
|
|
|
|
user_name => $user, |
|
59
|
|
|
|
|
|
|
active => 't', |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
unless ( @user_row ) { |
|
63
|
0
|
|
|
|
|
0
|
$r->note_basic_auth_failure; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Force disconnect from database due to failure. |
|
66
|
0
|
|
|
|
|
0
|
$user_model->disconnect(); |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'HTTP_UNAUTHORIZED' ) ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Do error here. |
|
72
|
0
|
0
|
0
|
|
|
0
|
unless ( defined $user_row[0]->crypt && $user_row[0]->crypt ) { |
|
73
|
0
|
|
|
|
|
0
|
$r->note_basic_auth_failure; |
|
74
|
0
|
|
|
|
|
0
|
$r->log_error(' [login failure: ', $self->remote_ip( $r ), ']', |
|
75
|
|
|
|
|
|
|
" user $user ($sent_pw) passwd not defined ", $r->uri ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Force disconnect from database due to failure. |
|
78
|
0
|
|
|
|
|
0
|
$user_model->disconnect(); |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'HTTP_UNAUTHORIZED' ) ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Do a error here as well. |
|
84
|
0
|
0
|
|
|
|
0
|
unless ( crypt( $sent_pw, $user_row[0]->crypt ) |
|
85
|
|
|
|
|
|
|
eq $user_row[0]->crypt ) { |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
$r->note_basic_auth_failure; |
|
88
|
0
|
|
|
|
|
0
|
$r->log_error(' [login failure: ', $self->remote_ip( $r ), ']', |
|
89
|
|
|
|
|
|
|
" user $user ($sent_pw) passwd mismatch ", $r->uri ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Force disconnect from database due to failure. |
|
92
|
0
|
|
|
|
|
0
|
$user_model->disconnect(); |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'HTTP_UNAUTHORIZED' ) ); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
return( $self->status_const( 'OK' ) ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} # END $self->handler |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#------------------------------------------------- |
|
102
|
|
|
|
|
|
|
# $self->import( @options ) |
|
103
|
|
|
|
|
|
|
#------------------------------------------------- |
|
104
|
|
|
|
|
|
|
sub import { |
|
105
|
1
|
|
|
1
|
|
12
|
my ( $self, @options ) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
2
|
my( $engine, $tplugin ); |
|
108
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
11
|
foreach (@options) { |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# Import the proper engine |
|
112
|
0
|
0
|
|
|
|
|
if (/^-Engine=(.*)$/) { |
|
113
|
0
|
|
|
|
|
|
$engine = "Gantry::Engine::$1"; |
|
114
|
0
|
|
|
|
|
|
eval "use $engine"; |
|
115
|
0
|
0
|
|
|
|
|
if ( $@ ) { |
|
116
|
0
|
|
|
|
|
|
die "unable to load engine $1 ($@)"; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} # end: import |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# EOF |
|
125
|
|
|
|
|
|
|
1; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |