| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
7
|
|
|
7
|
|
945
|
use strict; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
216
|
|
|
2
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
958
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mojolicious::Plugin::DigestAuth::DB; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub get |
|
7
|
|
|
|
|
|
|
{ |
|
8
|
35
|
|
|
35
|
0
|
149
|
my ($self, $realm, $user) = @_; |
|
9
|
35
|
50
|
33
|
|
|
184
|
return unless defined $realm and defined $user; |
|
10
|
35
|
|
|
|
|
162
|
$self->{users}->{$realm}->{$user}; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Mojolicious::Plugin::DigestAuth::DB::File; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = 'Mojolicious::Plugin::DigestAuth::DB'; |
|
16
|
7
|
|
|
7
|
|
61
|
use Carp 'croak'; |
|
|
7
|
|
|
|
|
103
|
|
|
|
7
|
|
|
|
|
2257
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
3
|
|
|
3
|
|
1927
|
my ($class, $file) = @_; |
|
21
|
3
|
50
|
|
|
|
11
|
croak 'usage: ', __PACKAGE__, '->new(FILE)' unless $file; |
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
6
|
local $_; |
|
24
|
3
|
|
|
|
|
6
|
my $users = {}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
3
|
100
|
|
|
|
251
|
open my $passwords, '<', $file or croak "error opening digest file '$file': $!"; |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
45
|
while(<$passwords>) { |
|
29
|
4
|
|
|
|
|
11
|
chomp; |
|
30
|
4
|
50
|
|
|
|
10
|
next unless $_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# user:realm:hashed_password |
|
33
|
4
|
|
|
|
|
15
|
my @user = split ':', $_, 3; |
|
34
|
4
|
100
|
66
|
|
|
20
|
if(@user != 3 || length $user[1] == 0) { |
|
35
|
1
|
|
|
|
|
144
|
croak "password file '$file' contains an invalid entry: $_"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
21
|
$users->{$user[1]}->{$user[0]} = $user[2]; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
28
|
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
|
|
53
|
use Carp 'croak'; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
437
|
|
|
49
|
7
|
|
|
7
|
|
62
|
use Mojolicious::Plugin::DigestAuth::Util 'checksum'; |
|
|
7
|
|
|
|
|
26
|
|
|
|
7
|
|
|
|
|
1660
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub new |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
72
|
|
|
72
|
|
871
|
my ($class, $config) = @_; |
|
54
|
72
|
100
|
66
|
|
|
606
|
croak 'usage: ', __PACKAGE__, '->new(HASH)' unless $config and ref $config eq 'HASH'; |
|
55
|
|
|
|
|
|
|
|
|
56
|
71
|
|
|
|
|
138
|
my $users; |
|
57
|
71
|
|
|
|
|
294
|
for my $realm (keys %$config) { |
|
58
|
72
|
50
|
|
|
|
238
|
croak "config for realm '$realm' is invalid: values must be a HASH" unless ref $config->{$realm} eq 'HASH'; |
|
59
|
72
|
|
|
|
|
167
|
while(my ($user, $password) = each %{$config->{$realm}}) { |
|
|
146
|
|
|
|
|
622
|
|
|
60
|
74
|
|
|
|
|
277
|
$users->{$realm}->{$user} = checksum($user, $realm, $password); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
71
|
|
|
|
|
362
|
bless { users => $users }, $class; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |