FreeBSD Bugzilla – Attachment 160792 Details for
Bug 202946
net/p5-Net-Amazon-Signature-V4 fixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch fixing aws4 issues
aws4.patch (text/plain), 6.31 KB, created by
Steven Hartland
on 2015-09-07 09:28:30 UTC
(
hide
)
Description:
patch fixing aws4 issues
Filename:
MIME Type:
Creator:
Steven Hartland
Created:
2015-09-07 09:28:30 UTC
Size:
6.31 KB
patch
obsolete
>Index: Makefile >=================================================================== >--- Makefile (revision 396253) >+++ Makefile (working copy) >@@ -14,10 +14,10 @@ LICENSE= ART10 GPLv1 > LICENSE_COMB= dual > > RUN_DEPENDS= \ >- p5-DateTime-Format-Strptime>0:${PORTSDIR}/devel/p5-DateTime-Format-Strptime \ >- p5-File-Slurp>0:${PORTSDIR}/devel/p5-File-Slurp \ >- p5-libwww>0:${PORTSDIR}/www/p5-libwww \ >- p5-Net>0:${PORTSDIR}/net/p5-Net >+ p5-URI>0:${PORTSDIR}/net/p5-URI \ >+ p5-Data-Dumper>0:${PORTSDIR}/devel/p5-Data-Dumper \ >+ p5-DateTime-Format-Strptime>0:${PORTSDIR}/devel/p5-DateTime-Format-Strptime \ >+ p5-Digest-SHA>0:${PORTSDIR}/security/p5-Digest-SHA > BUILD_DEPENDS= ${RUN_DEPENDS} > > USES= perl5 >Index: files/patch-Changes >=================================================================== >--- files/patch-Changes (revision 0) >+++ files/patch-Changes (working copy) >@@ -0,0 +1,16 @@ >+--- Changes 2013-02-26 19:14:07.000000000 +0000 >++++ Changes 2014-12-17 12:34:48.000000000 +0000 >+@@ -1,4 +1,13 @@ >+ Revision history for Net-Amazon-Signature-v4 >++0.14-pre 2014-12-17 >++ Remove dependency on perl 5.10 features. >++ >++ Ensure a date is always present, using X-Amz-Date if present. >++ >++ Remove spaces between Credential, SignedHeaders and Signature in the >++ header as per spec. >++ >++ Use \x0a line endings as per spec. >+ >+ 0.14 2013-02-26 >+ Allow client-side content-sha256 calculation. > >Property changes on: files/patch-Changes >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property >Index: files/patch-Net-Amazon-Signature-V4.pm >=================================================================== >--- files/patch-Net-Amazon-Signature-V4.pm (revision 0) >+++ files/patch-Net-Amazon-Signature-V4.pm (working copy) >@@ -0,0 +1,110 @@ >+--- lib/Net/Amazon/Signature/V4.pm 2013-02-26 19:12:47.000000000 +0000 >++++ lib/Net/Amazon/Signature/V4.pm 2014-12-17 12:30:38.000000000 +0000 >+@@ -1,6 +1,5 @@ >+ package Net::Amazon::Signature::V4; >+ >+-use 5.10.0; >+ use strict; >+ use warnings; >+ use sort 'stable'; >+@@ -74,6 +73,15 @@ sub sign { >+ return $request; >+ } >+ >++# _headers_to_sign: >++# Return the sorted lower case headers as required by the generation of canonical headers >++ >++sub _headers_to_sign { >++ my $req = shift; >++ >++ return sort { $a cmp $b } map { lc } $req->headers->header_field_names; >++} >++ >+ # _canonical_request: >+ # Construct the canonical request string from an HTTP::Request. >+ >+@@ -90,18 +98,17 @@ sub _canonical_request { >+ $creq_canonical_uri = _simplify_uri( $creq_canonical_uri ); >+ $creq_canonical_query_string = _sort_query_string( $creq_canonical_query_string ); >+ >+- my @sorted_headers = sort { lc($a) cmp lc($b) } $req->headers->header_field_names; >++ my @sorted_headers = _headers_to_sign( $req ); >+ my $creq_canonical_headers = join '', >+ map { >+- sprintf "%s:%s\n", >++ sprintf "%s:%s\x0a", >+ lc, >+ join ',', sort {$a cmp $b } _trim_whitespace($req->header($_) ) >+ } >+ @sorted_headers; >+ my $creq_signed_headers = join ';', map {lc} @sorted_headers; >+ my $creq_payload_hash = $req->header('x-amz-content-sha256') ? $req->header('x-amz-content-sha256') : sha256_hex( $req->content ); >+- >+- my $creq = join "\n", >++ my $creq = join "\x0a", >+ $creq_method, $creq_canonical_uri, $creq_canonical_query_string, >+ $creq_canonical_headers, $creq_signed_headers, $creq_payload_hash; >+ return $creq; >+@@ -112,13 +119,13 @@ sub _canonical_request { >+ >+ sub _string_to_sign { >+ my ( $self, $req ) = @_; >+- my $dt = _str_to_datetime( $req->header('Date') ); >++ my $dt = _req_datetime( $req ); >+ my $creq = $self->_canonical_request($req); >+ my $sts_request_date = $dt->strftime( '%Y%m%dT%H%M%SZ' ); >+ my $sts_credential_scope = join '/', $dt->strftime('%Y%m%d'), $self->{endpoint}, $self->{service}, 'aws4_request'; >+ my $sts_creq_hash = sha256_hex( $creq ); >+ >+- my $sts = join "\n", $ALGORITHM, $sts_request_date, $sts_credential_scope, $sts_creq_hash; >++ my $sts = join "\x0a", $ALGORITHM, $sts_request_date, $sts_credential_scope, $sts_creq_hash; >+ return $sts; >+ } >+ >+@@ -128,7 +135,7 @@ sub _string_to_sign { >+ sub _authorization { >+ my ( $self, $req ) = @_; >+ >+- my $dt = _str_to_datetime( $req->header('Date') ); >++ my $dt = _req_datetime( $req ); >+ my $sts = $self->_string_to_sign( $req ); >+ my $k_date = hmac_sha256( $dt->strftime('%Y%m%d'), 'AWS4' . $self->{secret} ); >+ my $k_region = hmac_sha256( $self->{endpoint}, $k_date ); >+@@ -137,9 +144,9 @@ sub _authorization { >+ >+ my $authz_signature = hmac_sha256_hex( $sts, $k_signing ); >+ my $authz_credential = join '/', $self->{access_key_id}, $dt->strftime('%Y%m%d'), $self->{endpoint}, $self->{service}, 'aws4_request'; >+- my $authz_signed_headers = join ';', sort { $a cmp $b } map { lc } $req->headers->header_field_names; >++ my $authz_signed_headers = join ';', _headers_to_sign( $req ); >+ >+- my $authz = "$ALGORITHM Credential=$authz_credential, SignedHeaders=$authz_signed_headers, Signature=$authz_signature"; >++ my $authz = "$ALGORITHM Credential=$authz_credential,SignedHeaders=$authz_signed_headers,Signature=$authz_signature"; >+ return $authz; >+ >+ } >+@@ -173,7 +180,7 @@ sub _sort_query_string { >+ my ( $key, $value ) = >+ map { tr/+/ /; uri_escape( uri_unescape( $_ ) ) } # escape all non-unreserved chars >+ split /=/, $param; >+- push @params, join '=', $key, ($value//''); >++ push @params, join '=', $key, (defined $value ? $value : ''); >+ } >+ return join '&', >+ #sort { $a cmp $b } >+@@ -208,6 +215,16 @@ sub _str_to_datetime { >+ return strptime( '%d %b %Y %H:%M:%S %Z', $date ); >+ } >+ } >++sub _req_datetime { >++ my $req = shift; >++ my $date = $req->header('X-Amz-Date') || $req->header('Date'); >++ if (!$date) { >++ # No date set by the caller so set one up >++ $req->date(time); >++ $date = $req->header('Date'); >++ } >++ return _str_to_datetime($date); >++} >+ >+ =head1 BUGS >+ > >Property changes on: files/patch-Net-Amazon-Signature-V4.pm >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 202946
: 160792