| 1 | package Net::Amazon::S3::Signature; | ||||||||||
| 2 | # ABSTRACT: S3 Signature implementation base class | ||||||||||
| 3 | 99 | $Net::Amazon::S3::Signature::VERSION = '0.99'; | |||||||||
| 4 | 99 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 99 | has http_request => ( | |||||||||
| 7 | is => 'ro', | ||||||||||
| 8 | isa => 'Net::Amazon::S3::HTTPRequest', | ||||||||||
| 9 | ); | ||||||||||
| 10 | |||||||||||
| 11 | sub _append_authorization_headers { | ||||||||||
| 12 | 210 | ▶ | my ($self, $request) = @_; | ||||||||
|
Subroutine
_append_authorization_headers: called CC=2 SCAR=6.9
| |||||||||||
| 13 | |||||||||||
| 14 | 210 | my %headers = $self->http_request->s3->authorization_context->authorization_headers; | |||||||||
| 15 | |||||||||||
| 16 | 210 | ▶ | while (my ($key, $value) = each %headers) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 1 | $self->_populate_default_header ($request, $key => $value); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 210 | (); | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub _append_authorization_query_params { | ||||||||||
| 24 | 6 | ▶ | my ($self, $request) = @_; | ||||||||
|
Subroutine
_append_authorization_query_params: called CC=2 SCAR=7.4
| |||||||||||
| 25 | |||||||||||
| 26 | 6 | my %headers = $self->http_request->s3->authorization_context->authorization_headers; | |||||||||
| 27 | |||||||||||
| 28 | 6 | ▶ | while (my ($key, $value) = each %headers) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | $self->_populate_default_query_param ($request, $key => $value); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 6 | (); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub _populate_default_header { | ||||||||||
| 36 | 1 | ▶ | my ($self, $request, $key, $value) = @_; | ||||||||
|
Subroutine
_populate_default_header: called CC=3 SCAR=11.3
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | ▶ | return unless defined $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 1 | ▶ | return if defined $request->header ($key); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | |||||||||||
| 41 | 1 | $request->header ($key => $value); | |||||||||
| 42 | |||||||||||
| 43 | 1 | (); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | sub _populate_default_query_param { | ||||||||||
| 47 | 0 | ▶ | my ($self, $request, $key, $value) = @_; | ||||||||
|
Subroutine
_populate_default_query_param: not called CC=3 SCAR=24.8
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | return unless defined $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | ▶ | return if defined $request->uri->query_param ($key); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | $request->uri->query_param ($key => $value); | |||||||||
| 53 | |||||||||||
| 54 | 0 | (); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | sub sign_request { | ||||||||||
| 58 | 0 | ▶ | my ($self, $request); | ||||||||
|
Subroutine
sign_request: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | return; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | sub sign_uri { | ||||||||||
| 64 | 0 | ▶ | my ($self, $uri, $expires_at); | ||||||||
|
Subroutine
sign_uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | return; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 99 | 1; | |||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||
| 72 | |||||||||||
| 73 | =pod | ||||||||||
| 74 | |||||||||||
| 75 | =encoding UTF-8 | ||||||||||
| 76 | |||||||||||
| 77 | =head1 NAME | ||||||||||
| 78 | |||||||||||
| 79 | Net::Amazon::S3::Signature - S3 Signature implementation base class | ||||||||||
| 80 | |||||||||||
| 81 | =head1 VERSION | ||||||||||
| 82 | |||||||||||
| 83 | version 0.99 | ||||||||||
| 84 | |||||||||||
| 85 | =head1 METHODS | ||||||||||
| 86 | |||||||||||
| 87 | =head2 new | ||||||||||
| 88 | |||||||||||
| 89 | Signature class should accept HTTPRequest instance and determine every | ||||||||||
| 90 | required parameter via this instance | ||||||||||
| 91 | |||||||||||
| 92 | =head2 sign_request( $request ) | ||||||||||
| 93 | |||||||||||
| 94 | Signature class should return authenticated request based on given parameter. | ||||||||||
| 95 | Parameter can be modified. | ||||||||||
| 96 | |||||||||||
| 97 | =head2 sign_uri( $request, $expires_at?, $method? ) | ||||||||||
| 98 | |||||||||||
| 99 | Signature class should return authenticated uri based on given request. | ||||||||||
| 100 | |||||||||||
| 101 | $expires_at is expiration time in seconds (epoch). | ||||||||||
| 102 | Default and maximal allowed value may depend on signature version. | ||||||||||
| 103 | |||||||||||
| 104 | Default request date is current time. | ||||||||||
| 105 | Signature class should accept provided C<< X-Amz-Date >> header instead (if signing request) | ||||||||||
| 106 | or query parameter (if signing uri) | ||||||||||
| 107 | |||||||||||
| 108 | =head1 AUTHOR | ||||||||||
| 109 | |||||||||||
| 110 | Branislav Zahradník <barney@cpan.org> | ||||||||||
| 111 | |||||||||||
| 112 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 113 | |||||||||||
| 114 | This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. | ||||||||||
| 115 | |||||||||||
| 116 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 117 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 118 | |||||||||||
| 119 | =cut | ||||||||||