line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sledge::Authorizer::BasicAuth; |
2
|
1
|
|
|
1
|
|
20786
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw(Sledge::Authorizer Class::Data::Inheritable); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1376
|
|
5
|
1
|
|
|
1
|
|
357
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
916
|
use MIME::Base64 qw//; |
|
1
|
|
|
|
|
707
|
|
|
1
|
|
|
|
|
255
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('error_template'); |
12
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata(realm => 'Authorization Required'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub basic_auth { |
15
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
16
|
0
|
|
|
|
|
|
my $page = shift; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
0
|
|
|
|
my $auth_header = $page->r->header_in('Authorization') || ''; |
19
|
0
|
0
|
|
|
|
|
if ($auth_header =~ /^Basic (.+)$/) { |
20
|
0
|
|
|
|
|
|
my ($user, $pass) = split q{:}, MIME::Base64::decode_base64($1); |
21
|
0
|
0
|
0
|
|
|
|
if (defined $user and defined $pass) { |
22
|
0
|
|
|
|
|
|
return ($user, $pass); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
return $self->show_error_page($page); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub show_error_page { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my $page = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$page->load_template($self->error_template); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $realm = $self->realm; |
35
|
0
|
|
|
|
|
|
$page->r->header_out('WWW-Authenticate' => qq{Basic realm="$realm"}); |
36
|
0
|
|
|
|
|
|
$page->r->status(401); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
$page->output_content; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |