Skip to content

Commit 5b0d8de

Browse files
committed
fix refresh token bug, set default region in signature when endpoint is not amazon
1 parent dc2cc6e commit 5b0d8de

6 files changed

Lines changed: 33 additions & 20 deletions

File tree

ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
Mon Jun 23 06:15:12 2025 Rob Lauer <rlauer6@comcast.net>
2+
3+
[2.1.4]:
4+
* VERSION: bump
5+
* README.md: generated
6+
* cpan/buildspec.yml: cpan/test_requires, cpan/requires
7+
* src/main/perl/lib/Amazon/API.pm.in
8+
(get_valid_token):
9+
- return if no token
10+
- $credentials->can('refresh_token'), not $self
11+
* src/main/perl/lib/Amazon/API/Signature4.pm.in
12+
(parse_service_url)
13+
- set default region when endpoint is not amazon
14+
115
Tue Feb 25 08:40:57 2025 Rob Lauer <rlauer6@comcast.net>
216

317
[2.1.3]:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.3
1+
2.1.4

cpan/buildspec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ project:
66
pm_module: Amazon::API
77
min-perl-version: 5.010
88
dependencies:
9-
test_requires: test-requires
10-
requires: requires
9+
test_requires: cpan/test-requires
10+
requires: cpan/requires
1111
path:
1212
pm_module: src/main/perl/lib
1313
tests: src/main/perl/t

src/main/perl/lib/Amazon/API.pm.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,10 +1650,13 @@ sub get_valid_token {
16501650

16511651
my $credentials = $self->get_credentials;
16521652

1653+
return
1654+
if !$credentials->get_token;
1655+
16531656
if ( $credentials->can('is_token_expired') ) {
16541657
if ( $credentials->is_token_expired ) {
16551658

1656-
if ( !$self->can('refresh_token') || !$credentials->refresh_token ) {
1659+
if ( !$credentials->can('refresh_token') || !$credentials->refresh_token ) {
16571660
croak 'token expired';
16581661
}
16591662
}

src/main/perl/lib/Amazon/API/Signature4.pm.in

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ use parent qw( Exporter AWS::Signature4 );
77

88
our $VERSION = '@PACKAGE_VERSION@';
99

10-
our @EXPORT_OK = qw{ parse_service_url };
10+
our @EXPORT_OK = qw( parse_service_url );
1111

1212
our @SERVICE_URL_REGEXP = (
13-
qr/(s3)[.]amazonaws[.]com\z/xsm,
14-
qr/(s3)[.]([^.]+)[.]amazonaws[.]com\z/xsm,
15-
qr/(s3)[.][^.]+[.]([^.]+)[.]amazonaws[.]com\z/xsm,
16-
qr/(s3)[-][^.]+.+[.]([^.]+)[.]amazonaws[.]com\z/xsm,
17-
qr/^([[:alpha:]-]+)[.]amazonaws[.]com\z/xsm,
18-
qr/^([[:alpha:]-]+)[.]([^.]*)[.]amazonaws[.]com/xsm,
13+
qr/(s3)[.]amazonaws[.]com\z/xsm, qr/(s3)[.]([^.]+)[.]amazonaws[.]com\z/xsm,
14+
qr/(s3)[.][^.]+[.]([^.]+)[.]amazonaws[.]com\z/xsm, qr/(s3)[-][^.]+.+[.]([^.]+)[.]amazonaws[.]com\z/xsm,
15+
qr/^([[:alpha:]-]+)[.]amazonaws[.]com\z/xsm, qr/^([[:alpha:]-]+)[.]([^.]*)[.]amazonaws[.]com/xsm,
1916
);
2017

2118
########################################################################
@@ -33,7 +30,7 @@ sub new {
3330
@{$self}{@extra} = @args{@extra};
3431

3532
return $self;
36-
} ## end sub new
33+
}
3734

3835
########################################################################
3936
sub parse_service_url {
@@ -46,18 +43,17 @@ sub parse_service_url {
4643
if ( !$service || !$region ) {
4744
foreach my $regexp (@SERVICE_URL_REGEXP) {
4845
if ( $host =~ $regexp ) {
49-
# print Dumper [ $host, $regexp ];
50-
5146
$service = $1;
5247
$region = $2 || $region || $default_region;
5348
last;
54-
} ## end if ( $host =~ $regexp )
49+
}
50+
}
51+
}
5552

56-
} ## end foreach my $regexp (@SERVICE_URL_REGEXP)
57-
} ## end if ( !$service || !$region)
53+
$region ||= $default_region;
5854

5955
return ( $host, $service, $region );
60-
} ## end sub parse_service_url
56+
}
6157

6258
###############################################################
6359
sub scope {
@@ -84,7 +80,7 @@ sub _scope {
8480
);
8581

8682
return "$date/$region/$service/aws4_request";
87-
} ## end sub _scope
83+
}
8884

8985
1;
9086

src/main/perl/lib/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ by passing the `content_type` option to the constructor.
964964

965965
# VERSION
966966

967-
This documentation refers to version 2.1.3 of `Amazon::API`.
967+
This documentation refers to version 2.1.4 of `Amazon::API`.
968968

969969
# DIAGNOSTICS
970970

0 commit comments

Comments
 (0)