line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: V4 signatures |
2
|
|
|
|
|
|
|
$Net::Amazon::S3::Signature::V4::VERSION = '0.991'; |
3
|
|
|
|
|
|
|
use Moose; |
4
|
99
|
|
|
99
|
|
646
|
|
|
99
|
|
|
|
|
234
|
|
|
99
|
|
|
|
|
588
|
|
5
|
|
|
|
|
|
|
use Net::Amazon::S3::Signature::V4Implementation; |
6
|
99
|
|
|
99
|
|
567640
|
use Digest::SHA; |
|
99
|
|
|
|
|
311
|
|
|
99
|
|
|
|
|
3029
|
|
7
|
99
|
|
|
99
|
|
673
|
use Ref::Util; |
|
99
|
|
|
|
|
214
|
|
|
99
|
|
|
|
|
2994
|
|
8
|
99
|
|
|
99
|
|
551
|
|
|
99
|
|
|
|
|
220
|
|
|
99
|
|
|
|
|
2871
|
|
9
|
|
|
|
|
|
|
use Net::Amazon::S3::Constants; |
10
|
99
|
|
|
99
|
|
541
|
use Net::Amazon::S3::Signature::V2; |
|
99
|
|
|
|
|
210
|
|
|
99
|
|
|
|
|
1961
|
|
11
|
99
|
|
|
99
|
|
528
|
|
|
99
|
|
|
|
|
209
|
|
|
99
|
|
|
|
|
2037
|
|
12
|
|
|
|
|
|
|
use namespace::clean; |
13
|
99
|
|
|
99
|
|
508
|
|
|
99
|
|
|
|
|
222
|
|
|
99
|
|
|
|
|
989
|
|
14
|
|
|
|
|
|
|
extends 'Net::Amazon::S3::Signature'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
1; |
17
|
|
|
|
|
|
|
} |
18
|
2
|
|
|
2
|
0
|
47
|
|
19
|
|
|
|
|
|
|
my ($self, $http_request, $response, $ua, $h) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $region = $response->header(Net::Amazon::S3::Constants->HEADER_BUCKET_REGION) or return; |
22
|
0
|
|
|
0
|
0
|
0
|
|
23
|
|
|
|
|
|
|
# change the bucket region in request |
24
|
0
|
0
|
|
|
|
0
|
my $request = $response->request; |
25
|
|
|
|
|
|
|
$request->uri( $response->header( 'location' ) ); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
# sign the request again |
28
|
0
|
|
|
|
|
0
|
$request->headers->remove_header('Authorization'); |
29
|
|
|
|
|
|
|
$request->headers->remove_header(Net::Amazon::S3::Constants->HEADER_DATE); |
30
|
|
|
|
|
|
|
$http_request->_sign_request( $request, $region ); |
31
|
0
|
|
|
|
|
0
|
|
32
|
0
|
|
|
|
|
0
|
return $request; |
33
|
0
|
|
|
|
|
0
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
my ($self, $region) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return Net::Amazon::S3::Signature::V4Implementation->new( |
38
|
|
|
|
|
|
|
$self->http_request->s3->aws_access_key_id, |
39
|
7
|
|
|
7
|
|
18
|
$self->http_request->s3->aws_secret_access_key, |
40
|
|
|
|
|
|
|
$region || $self->http_request->region, |
41
|
7
|
|
33
|
|
|
166
|
's3', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my ($self, $sign, $request) = @_; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $host = $request->uri->host; |
48
|
|
|
|
|
|
|
return if $sign->{endpoint} eq 'us-east-1'; |
49
|
|
|
|
|
|
|
return unless $host =~ s/(?<=\bs3)(?=\.amazonaws\.com$)/"-" . $sign->{endpoint}/e; |
50
|
7
|
|
|
7
|
|
13
|
|
51
|
|
|
|
|
|
|
$request->uri->host( $host ); |
52
|
7
|
|
|
|
|
24
|
} |
53
|
7
|
100
|
|
|
|
532
|
|
54
|
6
|
100
|
|
|
|
33
|
my ($self, $request, $region) = @_; |
|
4
|
|
|
|
|
17
|
|
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
10
|
my $sha = Digest::SHA->new( '256' ); |
57
|
|
|
|
|
|
|
if (Ref::Util::is_coderef( my $coderef = $request->content )) { |
58
|
|
|
|
|
|
|
while (length (my $snippet = $coderef->())) { |
59
|
|
|
|
|
|
|
$sha->add ($snippet); |
60
|
1
|
|
|
1
|
1
|
638
|
} |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
8
|
$request->header( $Net::Amazon::S3::Signature::V4Implementation::X_AMZ_CONTENT_SHA256 => $sha->hexdigest ); |
63
|
1
|
50
|
|
|
|
21
|
} |
64
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
|
|
0
|
$self->_append_authorization_headers ($request); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $sign = $self->_sign( $region ); |
68
|
0
|
|
|
|
|
0
|
$self->_host_to_region_host( $sign, $request ); |
69
|
|
|
|
|
|
|
$sign->sign( $request ); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
21
|
return $request; |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
4
|
|
74
|
1
|
|
|
|
|
5
|
my ($self, $request, $expires_at) = @_; |
75
|
1
|
|
|
|
|
4
|
|
76
|
|
|
|
|
|
|
$self->_append_authorization_query_params ($request); |
77
|
1
|
|
|
|
|
11
|
|
78
|
|
|
|
|
|
|
my $sign = $self->_sign; |
79
|
|
|
|
|
|
|
$self->_host_to_region_host( $sign, $request ); |
80
|
|
|
|
|
|
|
|
81
|
6
|
|
|
6
|
1
|
15
|
return $sign->sign_uri( $request->uri, $expires_at - time, $request->method ); |
82
|
|
|
|
|
|
|
} |
83
|
6
|
|
|
|
|
31
|
|
84
|
|
|
|
|
|
|
1; |
85
|
6
|
|
|
|
|
16
|
|
86
|
6
|
|
|
|
|
20
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
6
|
|
|
|
|
330
|
|
89
|
|
|
|
|
|
|
=encoding UTF-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Net::Amazon::S3::Signature::V4 - V4 signatures |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 0.991 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |