diff options
Diffstat (limited to 'lib/App/Glacier/Signature.pm')
-rw-r--r-- | lib/App/Glacier/Signature.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/App/Glacier/Signature.pm b/lib/App/Glacier/Signature.pm new file mode 100644 index 0000000..10d0ea7 --- /dev/null +++ b/lib/App/Glacier/Signature.pm @@ -0,0 +1,24 @@ +package App::Glacier::Signature; + +# A wrapper class over Net::Amazon::Signature::V4, that supplies +# the X-Amz-Security-Token header for EC2 instance profile authentication. +sub new { + my ($class, $sig, $token) = @_; + bless { _sig => $sig, _token => $token }, $class; +}; + +sub sign { + my ($self, $request) = @_; + $request->header('X-Amz-Security-Token' => $self->{_token}); + return $self->{_sig}->sign($request); +} + +our $AUTOLOAD; + +sub AUTOLOAD { + my $self = shift; + (my $meth = $AUTOLOAD) =~ s/.*:://; + $self->{_sig}->method(@_); +} + +1; |