| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Protocol::Database::PostgreSQL::Backend::AuthenticationRequest; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '2.000'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use parent qw(Protocol::Database::PostgreSQL::Backend); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Protocol::Database::PostgreSQL::Backend::AuthenticationRequest - an authentication request message |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
51
|
use Log::Any qw($log); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
0
|
0
|
0
|
sub type { 'authentication_request' } |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
0
|
0
|
sub auth_type { shift->{auth_type} } |
|
23
|
0
|
|
|
0
|
0
|
0
|
sub password_type { shift->{password_type} } |
|
24
|
0
|
|
|
0
|
0
|
0
|
sub password_salt { shift->{password_salt} } |
|
25
|
0
|
|
|
0
|
0
|
0
|
sub password_rounds { shift->{password_rounds} } |
|
26
|
0
|
|
|
0
|
0
|
0
|
sub password_nonce { shift->{password_nonce} } |
|
27
|
0
|
|
|
0
|
0
|
0
|
sub server_first_message { shift->{server_first_message} } |
|
28
|
0
|
|
|
0
|
0
|
0
|
sub server_signature { shift->{server_signature} } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new_from_message { |
|
31
|
1
|
|
|
1
|
1
|
3
|
my ($class, $msg) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
6
|
my (undef, undef, $auth_code, $data) = unpack('C1N1N1a*', $msg); |
|
34
|
1
|
50
|
|
|
|
4
|
my $auth_type = $Protocol::Database::PostgreSQL::AUTH_TYPE{$auth_code} or die "Invalid auth code $auth_code received"; |
|
35
|
1
|
|
|
|
|
4
|
$log->tracef("Auth message [%s]", $auth_type); |
|
36
|
1
|
|
|
|
|
5
|
my %info = ( |
|
37
|
|
|
|
|
|
|
auth_type => $auth_type, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
1
|
50
|
|
|
|
4
|
if($auth_type eq 'AuthenticationMD5Password') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
my ($salt) = unpack('a4', $data); |
|
41
|
0
|
|
|
|
|
0
|
$info{password_type} = 'md5'; |
|
42
|
0
|
|
|
|
|
0
|
$info{password_salt} = $salt; |
|
43
|
|
|
|
|
|
|
} elsif($auth_type eq 'AuthenticationCleartextPassword') { |
|
44
|
1
|
|
|
|
|
3
|
$info{password_type} = 'plain'; |
|
45
|
|
|
|
|
|
|
} elsif($auth_type eq 'AuthenticationOk') { |
|
46
|
|
|
|
|
|
|
# No action required |
|
47
|
|
|
|
|
|
|
} elsif($auth_type eq 'AuthenticationSASL') { |
|
48
|
0
|
|
|
|
|
0
|
my @methods = split /\0/, $data; |
|
49
|
0
|
|
|
|
|
0
|
$log->tracef('Have auth methods %s', \@methods); |
|
50
|
0
|
|
|
|
|
0
|
$info{password_mechanisms} = \@methods; |
|
51
|
|
|
|
|
|
|
} elsif($auth_type eq 'AuthenticationSASLContinue') { |
|
52
|
0
|
|
|
|
|
0
|
$log->tracef('Auth continue: %s', $data); |
|
53
|
0
|
|
|
|
|
0
|
my %data = map { /([rsi])=(.*)$/ } split /,/, $data; |
|
|
0
|
|
|
|
|
0
|
|
|
54
|
0
|
|
|
|
|
0
|
$log->tracef('Have parameters: %s', \%data); |
|
55
|
0
|
|
|
|
|
0
|
$info{password_rounds} = $data{i}; |
|
56
|
0
|
|
|
|
|
0
|
$info{password_salt} = $data{s}; |
|
57
|
0
|
|
|
|
|
0
|
$info{password_nonce} = $data{r}; |
|
58
|
0
|
|
|
|
|
0
|
$info{server_first_message} = $data; |
|
59
|
|
|
|
|
|
|
} elsif($auth_type eq 'AuthenticationSASLFinal') { |
|
60
|
0
|
|
|
|
|
0
|
$log->tracef('Auth final %s', $data); |
|
61
|
0
|
|
|
|
|
0
|
my %data = map { /([v])=(.*)$/ } split /,/, $data; |
|
|
0
|
|
|
|
|
0
|
|
|
62
|
0
|
|
|
|
|
0
|
$log->tracef('Have parameters: %s', \%data); |
|
63
|
0
|
|
|
|
|
0
|
$info{server_signature} = $data{v}; |
|
64
|
|
|
|
|
|
|
} else { |
|
65
|
0
|
|
|
|
|
0
|
die 'unknown auth thing here'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
1
|
|
|
|
|
9
|
return $class->new( |
|
68
|
|
|
|
|
|
|
%info, |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Tom Molesworth |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Copyright Tom Molesworth 2010-2019. Licensed under the same terms as Perl itself. |
|
81
|
|
|
|
|
|
|
|