lstein / aws-signature4 Goto Github PK
View Code? Open in Web Editor NEWPerl module for generating Version 4 signatures for use with Amazon Web Services
License: Artistic License 2.0
Perl module for generating Version 4 signatures for use with Amazon Web Services
License: Artistic License 2.0
e.g.
$signer->sign( $request, region => "ProductAdvertisingAPI", service => "eu-west-1" );
Also, suggest adding to the perldoc
# useful for debugging
warn $request->headers_as_string();
and reference to the code on github :)
Thanks for your work on this, very much appreciated!
Greetings,
I was attempting to use your module to sign requests for the ElasticSearch service the other day and identified that your regex cases don't include some of AWS's newer services, such as ES. Here's a patch which generically supports a number of newer AWS services which follow this URL scheme. Note that it may also match some URLs which aren't a valid service, but I figure as a generic catch-all at the bottom of this elsif list this should be a safe enough addition. At the very least, I figure it'll generate errors in the same way that the us-east-1/S3 defaults would do for most cases.
I haven't used Github to contribute before; not sure if I would have the ability to directly commit/upload this patch or not, so I'm including the diff in this issue report (it's small). Let me know if you'd like me to push the change to the project.
Thanks!
shaneallen@localhost:~/AWS-Signature4/lib/AWS$ diff -u Signature4.pm.old Signature4.pm
--- Signature4.pm.old 2017-07-27 08:28:36.128251822 -0500
+++ Signature4.pm 2017-07-28 08:04:22.483102296 -0500
@@ -243,6 +243,9 @@
} elsif ($host =~ /^([\w-]+)\.amazonaws\.com/) {
$service = $1;
$region = 'us-east-1';
+ } elsif ($host =~ /^[\w-]+\.([\w-]+)\.([\w-]+)\.amazonaws\.com/) {
+ $service = $2;
+ $region = $1;
}
$service ||= 's3';
$region ||= 'us-east-1'; # default
Hi
I change manually the module for support differente scope and works fine .
With pinpoint url for rest api for us-east-1 :
https://pinpoint.us-east-1.amazonaws.com/v1/apps/APPID/events
But scope must be mobiletargeting , not pinpoint .
May be the scope can pass on signed post ?
I add this in sub :
if ( $service = 'pinpoint' )
{
$service = 'mobiletargeting';
}
sub _scope {
my $self = shift;
my ($request,$region) = @_;
my $host = $request->uri->host;
my $datetime = $self->_datetime($request);
my ($date) = $datetime =~ /^(\d+)T/;
my $service;
if ($host =~ /^([\w.-]+)\.s3\.amazonaws.com/) { # S3 bucket virtual host
$service = 's3';
$region ||= 'us-east-1';
} elsif ($host =~ /^[\w-]+\.s3-([\w-]+)\.amazonaws\.com/) {
$service = 's3';
$region ||= $2;
} elsif ($host =~ /^(\w+)[-.]([\w-]+)\.amazonaws\.com/) {
$service = $1;
$region ||= $2;
} elsif ($host =~ /^([\w-]+)\.amazonaws\.com/) {
$service = $1;
$region = 'us-east-1';
}
if ( $service = 'pinpoint' )
{
$service = 'mobiletargeting';
}
$service ||= 's3';
$region ||= 'us-east-1'; # default
return "$date/$region/$service/aws4_request";
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.