Amazon-Signature4-Lite

 view release on metacpan or  search on metacpan

lib/Amazon/Signature4/Lite.pm  view on Meta::CPAN


Optional hash reference containing additional request headers to include
in the signature.

=item payload

The request body. The SHA-256 hash used in the canonical request is
calculated from this value.

If neither C<payload> nor C<payload_hash> is supplied, the payload is
treated as an empty string.

=item payload_hash

An optional precomputed SHA-256 hash of the request body.

When supplied, C<payload_hash> is used directly in the canonical request
and, by default, as the value of the C<x-amz-content-sha256> header. The
C<payload> value is not hashed.

This is useful when the request body will be streamed and holding the
complete payload in memory solely for signing would be undesirable. The
caller is responsible for ensuring that C<payload_hash> corresponds
exactly to the content that will be transmitted.

my $headers = $signer->sign(
method       => 'PUT',
url          => $url,
headers      => %extra_headers,
payload_hash => $sha256,
);

=item add_sha256_header

Controls whether C<x-amz-content-sha256> is included in the returned
headers. Defaults to true.

=item time

Optional Unix timestamp used when generating the signing timestamp.
When omitted, the current time is used. This is primarily useful for
testing or applications that need to control the signing time.

=back

The returned hash reference includes C<Authorization>, C<x-amz-date>,
C<host>, and, by default, C<x-amz-content-sha256>. It also includes
C<x-amz-security-token> when the signer was constructed with a session
token.

The returned hash reference can be passed directly as the headers for an
L<HTTP::Tiny> request.

=head2 parse_service_url(%args)

  my ($host, $service, $region) = Amazon::Signature4::Lite->parse_service_url(
    host           => 's3.us-east-2.amazonaws.com',
    default_region => 'us-east-1',
  );

Extracts service name and region from an AWS endpoint URL. Can be
called as a class or instance method.

I<Note: The patterns used for parsing are S3/AWS endpoint focused, not
a general URL parser.>

=head1 DEPENDENCIES

All dependencies are Perl core modules (since 5.10) or already
required by distributions in the Amazon::* toolchain:

=over 4

=item * L<Digest::SHA> (core since 5.10)

=item * L<MIME::Base64> (core)

=item * L<POSIX> (core)

=item * L<URI::Escape>

=back

=head1 SEE ALSO

L<AWS::Signature4>, L<Signer::AWSv4>, L<Amazon::S3::Lite>

=cut



( run in 0.858 second using v1.01-cache-2.11-cpan-7e1922ba9f2 )