Skip to content

Commit 214bfed

Browse files
MatthewHepburndekobon
authored andcommitted
Handle non-unixtime expiration
At least in Fargate, credentials have a human-readable expiration time, not a unix timestamp. Multiplying that by 1000 breaks the check on expiration.
1 parent e2a7512 commit 214bfed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common/etc/nginx/include/s3gateway.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,9 @@ async function fetchCredentials(r) {
988988
}
989989

990990
if (current) {
991-
// AWS returns Unix timestamps in seconds, but in Date constructor we should provide timestamp in milliseconds
992-
const exp = new Date(current.expiration * 1000).getTime() - maxValidityOffsetMs;
991+
// If AWS returns a Unix timestamp it will be in seconds, but in Date constructor we should provide timestamp in milliseconds
992+
const expireAt = typeof current.expiration == 'number' ? current.expiration * 1000 : current.expiration
993+
const exp = new Date(expireAt).getTime() - maxValidityOffsetMs;
993994
if (NOW.getTime() < exp) {
994995
r.return(200);
995996
return;

0 commit comments

Comments
 (0)