line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
7
|
|
|
7
|
|
554
|
use strict; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
176
|
|
2
|
7
|
|
|
7
|
|
24
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
550
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mojolicious::Plugin::DigestAuth::DB; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub get |
7
|
|
|
|
|
|
|
{ |
8
|
35
|
|
|
35
|
0
|
93
|
my ($self, $realm, $user) = @_; |
9
|
35
|
50
|
33
|
|
|
176
|
return unless defined $realm and defined $user; |
10
|
35
|
|
|
|
|
157
|
$self->{users}->{$realm}->{$user}; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Mojolicious::Plugin::DigestAuth::DB::File; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = 'Mojolicious::Plugin::DigestAuth::DB'; |
16
|
7
|
|
|
7
|
|
31
|
use Carp 'croak'; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
1355
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new |
19
|
|
|
|
|
|
|
{ |
20
|
3
|
|
|
3
|
|
953
|
my ($class, $file) = @_; |
21
|
3
|
50
|
|
|
|
8
|
croak 'usage: ', __PACKAGE__, '->new(FILE)' unless $file; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
3
|
local $_; |
24
|
3
|
|
|
|
|
4
|
my $users = {}; |
25
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
203
|
open my $passwords, '<', $file or croak "error opening digest file '$file': $!"; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
30
|
while(<$passwords>) { |
29
|
4
|
|
|
|
|
6
|
chomp; |
30
|
4
|
50
|
|
|
|
7
|
next unless $_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# user:realm:hashed_password |
33
|
4
|
|
|
|
|
12
|
my @user = split ':', $_, 3; |
34
|
4
|
100
|
66
|
|
|
17
|
if(@user != 3 || length $user[1] == 0) { |
35
|
1
|
|
|
|
|
104
|
croak "password file '$file' contains an invalid entry: $_"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
11
|
$users->{$user[1]}->{$user[0]} = $user[2]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
12
|
bless { users => $users }, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Mojolicious::Plugin::DigestAuth::DB::Hash; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our @ISA = 'Mojolicious::Plugin::DigestAuth::DB'; |
47
|
|
|
|
|
|
|
|
48
|
7
|
|
|
7
|
|
30
|
use Carp 'croak'; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
284
|
|
49
|
7
|
|
|
7
|
|
29
|
use Mojolicious::Plugin::DigestAuth::Util 'checksum'; |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
987
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new |
52
|
|
|
|
|
|
|
{ |
53
|
72
|
|
|
72
|
|
421
|
my ($class, $config) = @_; |
54
|
72
|
100
|
66
|
|
|
594
|
croak 'usage: ', __PACKAGE__, '->new(HASH)' unless $config and ref $config eq 'HASH'; |
55
|
|
|
|
|
|
|
|
56
|
71
|
|
|
|
|
99
|
my $users; |
57
|
71
|
|
|
|
|
171
|
for my $realm (keys %$config) { |
58
|
72
|
50
|
|
|
|
200
|
croak "config for realm '$realm' is invalid: values must be a HASH" unless ref $config->{$realm} eq 'HASH'; |
59
|
72
|
|
|
|
|
105
|
while(my ($user, $password) = each %{$config->{$realm}}) { |
|
146
|
|
|
|
|
1060
|
|
60
|
74
|
|
|
|
|
281
|
$users->{$realm}->{$user} = checksum($user, $realm, $password); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
71
|
|
|
|
|
364
|
bless { users => $users }, $class; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |