1AWS::Signature4(3)    User Contributed Perl Documentation   AWS::Signature4(3)
2
3
4

NAME

6       AWS::Signature4 - Create a version4 signature for Amazon Web Services
7

SYNOPSIS

9        use AWS::Signature4;
10        use HTTP::Request::Common;
11        use LWP;
12
13        my $signer = AWS::Signature4->new(-access_key => 'AKIDEXAMPLE',
14                                          -secret_key => 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY');
15        my $ua     = LWP::UserAgent->new();
16
17        # Example POST request
18        my $request = POST('https://iam.amazonaws.com',
19                           [Action=>'ListUsers',
20                            Version=>'2010-05-08']);
21        $signer->sign($request);
22        my $response = $ua->request($request);
23
24        # Example GET request
25        my $uri     = URI->new('https://iam.amazonaws.com');
26        $uri->query_form(Action=>'ListUsers',
27                         Version=>'2010-05-08');
28
29        my $url = $signer->signed_url($uri); # This gives a signed URL that can be fetched by a browser
30        my $response = $ua->get($url);
31

DESCRIPTION

33       This module implement's Amazon Web Service's Signature version 4
34       (http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
35

METHODS

37       $signer = AWS::Signature4->new(-access_key => $account_id,-secret_key
38       => $private_key);
39           Create a signing object using your AWS account ID and secret key.
40           You may also use the temporary security tokens received from
41           Amazon's STS service, either by passing the access and secret keys
42           derived from the token, or by passing a VM::EC2::Security::Token
43           produced by the VM::EC2 module.
44
45           Arguments:
46
47            Argument name       Argument Value
48            -------------       --------------
49            -access_key         An AWS acccess key (account ID)
50
51            -secret_key         An AWS secret key
52
53            -security_token     A VM::EC2::Security::Token object
54
55           If a security token is provided, it overrides any values given for
56           -access_key or -secret_key.
57
58           If the environment variables EC2_ACCESS_KEY and/or EC2_SECRET_KEY
59           are set, their contents are used as defaults for -acccess_key and
60           -secret_key.
61
62       $signer->sign($request [,$region] [,$payload_sha256_hex])
63           Given an HTTP::Request object, add the headers required by AWS and
64           then sign it with a version 4 signature by adding an
65           "Authorization" header.
66
67           The request must include a URL from which the AWS endpoint and
68           service can be derived, such as "ec2.us-east-1.amazonaws.com." In
69           some cases (e.g. S3 bucket operations) the endpoint does not
70           indicate the region. In this case, the region can be forced by
71           passing a defined value for $region. The current date and time will
72           be added to the request using an "X-Amz-Date header." To force the
73           date and time to a fixed value, include the "Date" header in the
74           request.
75
76           The request content, or "payload" is retrieved from the
77           HTTP::Request object by calling its content() method.. Under some
78           circumstances the payload is not included directly in the request,
79           but is in an external file that will be uploaded as the request is
80           executed. In this case, you must pass a second argument containing
81           the results of running sha256_hex() (from the Digest::SHA module)
82           on the content.
83
84           The method returns a true value if successful. On errors, it will
85           throw an exception.
86
87       $url = $signer->signed_url($request)
88           This method will generate a signed GET URL for the request. The URL
89           will include everything needed to perform the request.
90
91       my $url $signer->signed_url($request_or_uri [,$expires])
92           Pass an HTTP::Request, a URI object, or just a plain URL string
93           containing the proper endpoint and parameters needed for an AWS
94           REST API Call. This method will return an appropriately signed
95           request as a URI object, which can be shared with non-AWS users for
96           the purpose of, e.g., accessing an object in a private S3 bucket.
97
98           Pass an optional $expires argument to indicate that the URL will
99           only be valid for a finite period of time. The value of the
100           argument is in seconds.
101
102       $signing_key =
103       AWS::Signature4->signing_key($secret_access_key,$service_name,$region,$date)
104           Return just the signing key in the event you wish to roll your own
105           signature.
106

SEE ALSO

108       VM::EC2
109

AUTHOR

111       Lincoln Stein <lincoln.stein@gmail.com>.
112
113       Copyright (c) 2014 Ontario Institute for Cancer Research
114
115       This package and its accompanying libraries is free software; you can
116       redistribute it and/or modify it under the terms of the GPL (either
117       version 1, or at your option, any later version) or the Artistic
118       License 2.0.  Refer to LICENSE for the full license text. In addition,
119       please see DISCLAIMER.txt for disclaimers of warranty.
120

POD ERRORS

122       Hey! The above document had some coding errors, which are explained
123       below:
124
125       Around line 145:
126           '=item' outside of any '=over'
127
128       Around line 377:
129           You forgot a '=back' before '=head1'
130
131
132
133perl v5.32.0                      2020-07-28                AWS::Signature4(3)
Impressum