| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POE::Component::Server::HTTPServer::BasicAuthenHandler; |
|
2
|
1
|
|
|
1
|
|
1954
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use HTTP::Status; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
784
|
|
|
4
|
1
|
|
|
1
|
|
8
|
use MIME::Base64 qw( decode_base64 ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
69
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use POE::Component::Server::HTTPServer::Handler qw( H_CONT H_FINAL ); |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
93
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base 'POE::Component::Server::HTTPServer::Handler'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
764
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _init { |
|
9
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
10
|
0
|
|
|
|
|
|
my $realm = shift; |
|
11
|
0
|
|
|
|
|
|
$self->{realm} = $realm; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub handle { |
|
15
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
16
|
0
|
|
|
|
|
|
my $context = shift; |
|
17
|
0
|
|
|
|
|
|
my $cred = $context->{request}->header('Authorization'); |
|
18
|
0
|
0
|
0
|
|
|
|
if ( defined($cred) && $cred =~ /^Basic\s+(.*)$/ ) { |
|
19
|
0
|
|
|
|
|
|
my $unscrambled = decode_base64($1); |
|
20
|
0
|
0
|
|
|
|
|
if ( my($username,$password) = ( $unscrambled=~/^(.*?):(.*)/ ) ) { |
|
21
|
0
|
|
|
|
|
|
$context->{basic_username} = $username; |
|
22
|
0
|
|
|
|
|
|
$context->{basic_password} = $password; |
|
23
|
0
|
|
|
|
|
|
return H_CONT; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
# respond with basic auth challenge |
|
27
|
0
|
|
|
|
|
|
return $self->authen_challenge($context); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub authen_challenge { |
|
31
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
32
|
0
|
|
|
|
|
|
my $context = shift; |
|
33
|
0
|
|
|
|
|
|
my $realm = $self->{realm}; |
|
34
|
0
|
|
|
|
|
|
$context->{response}->header('WWW-Authenticate', |
|
35
|
|
|
|
|
|
|
qq{Basic realm="$realm"}); |
|
36
|
0
|
|
|
|
|
|
$context->{response}->code( RC_UNAUTHORIZED ); |
|
37
|
0
|
|
|
|
|
|
$context->{response}->content( "Unauthorized\n" ); |
|
38
|
0
|
|
|
|
|
|
return H_FINAL; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
__END__ |