Skip to content

Commit 8a5a950

Browse files
dm3chdekobon
authored andcommitted
Fix credentials caching
1 parent 93cb648 commit 8a5a950

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
@@ -882,7 +882,7 @@ function _require_env_var(envVarName) {
882882
*
883883
* @type {number}
884884
*/
885-
var maxValidityOffsetMs = 4.5 * 60 * 100;
885+
var maxValidityOffsetMs = 4.5 * 60 * 1000;
886886

887887
/**
888888
* Get the credentials needed to create AWS signatures in order to authenticate
@@ -918,7 +918,8 @@ async function fetchCredentials(r) {
918918
}
919919

920920
if (current) {
921-
var exp = new Date(current.expiration).getTime() - maxValidityOffsetMs;
921+
// AWS returns Unix timestamps in seconds, but in Date constructor we should provide timestamp in milliseconds
922+
var exp = new Date(current.expiration * 1000).getTime() - maxValidityOffsetMs;
922923
if (now.getTime() < exp) {
923924
r.return(200);
924925
return;

0 commit comments

Comments
 (0)