Akamai-Edgegrid
view release on metacpan or search on metacpan
lib/Akamai/Edgegrid.pm view on Meta::CPAN
package Akamai::Edgegrid;
use 5.006;
use strict;
use warnings FATAL => 'all';
use base 'LWP::UserAgent';
use Data::Dumper;
use Digest::SHA qw(hmac_sha256_base64 sha256_base64);
use POSIX qw(strftime);
use Data::UUID;
use Config::IniFiles;
=head1 NAME
Akamai::Edgegrid - User agent for Akamai {OPEN} Edgegrid
=head1 VERSION
Version 1.0
=cut
our $VERSION = '1.0.5';
=head1 SYNOPSIS
use Akamai::Edgegrid;
my $agent = new Akamai::Edgegrid(
config_file => "$ENV{HOME}/.edgerc",
section => "default");
my $baseurl = "https://" . $agent->{host};
my $resp = $agent->get("$baseurl/diagnostic-tools/v1/locations");
print $resp->content;
=head1 DESCRIPTION
This module implements the Akamai {OPEN} Edgegrid Authentication scheme as specified by L<https://developer.akamai.com/introduction/Client_Auth.html>.
=cut
sub _eg_timestamp {
return strftime('%Y%m%dT%H:%M:%S+0000', gmtime(time));
}
sub _new_nonce {
my $ug = new Data::UUID;
return $ug->create_str;
}
# see http://search.cpan.org/~mshelor/Digest-SHA-5.88/lib/Digest/SHA.pm#PADDING_OF_BASE64_DIGESTS
sub _pad_digest {
my $digest = shift;
while (length($digest) % 4) {
$digest .= '=';
}
return $digest;
}
sub _padded_hmac_sha256_base64 {
my ($data, $key) = @_;
return _pad_digest(hmac_sha256_base64($data, $key));
}
sub _padded_sha256_base64 {
my ($data) = @_;
( run in 1.255 second using v1.01-cache-2.11-cpan-0d23b851a93 )