line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Amazon::Signature; |
2
|
|
|
|
|
|
|
# ABSTRACT: support for various ways to sign AWS requests |
3
|
1
|
|
|
1
|
|
42047
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
WebService::Amazon::Signature - handle signatures for Amazon webservices |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 0.002 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $req = 'GET / HTTP/1.1 ...'; |
19
|
|
|
|
|
|
|
my $amz = WebService::Amazon::Signature->new( |
20
|
|
|
|
|
|
|
version => 4, |
21
|
|
|
|
|
|
|
algorithm => 'AWS4-HMAC-SHA256', |
22
|
|
|
|
|
|
|
scope => '20110909/us-east-1/host/aws4_request', |
23
|
|
|
|
|
|
|
access_key => 'AKIDEXAMPLE', |
24
|
|
|
|
|
|
|
secret_key => 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY', |
25
|
|
|
|
|
|
|
host_port => 'localhost:8000', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
$amz->parse_request($req) |
28
|
|
|
|
|
|
|
my $signed_req = $amz->signed_request($req); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Provides methods for signing requests and verifying responses for Amazon webservices, |
33
|
|
|
|
|
|
|
as described in L. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Note that most of this is subject to change over the next few versions. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
386
|
use WebService::Amazon::Signature::v4; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Instantiate a signing object. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Will extract the C named parameter, if it exists, and use that |
48
|
|
|
|
|
|
|
to select the appropriate subclass for instantiation. Other parameters |
49
|
|
|
|
|
|
|
are as defined by the subclass. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over 4 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * L |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * L |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
62
|
31
|
|
|
31
|
1
|
91407
|
my $class = shift; |
63
|
31
|
|
|
|
|
166
|
my %args = @_; |
64
|
31
|
|
50
|
|
|
141
|
my $version = delete $args{version} || 4; |
65
|
31
|
|
|
|
|
98
|
my $pkg = 'WebService::Amazon::Signature::v' . $version; |
66
|
31
|
50
|
|
|
|
343
|
if(my $code = $pkg->can('new')) { |
67
|
31
|
50
|
|
|
|
102
|
$class = $pkg if $class eq __PACKAGE__; |
68
|
31
|
|
|
|
|
241
|
return $code->($class, %args) |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
die "No support for version $version"; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |