File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ const (
3333 v4scopeTerminator = "aws4_request"
3434 v4timeFormat = "20060102T150405Z"
3535 v4shortTimeFormat = "20060102"
36- AmzPresignMaxExpires = 7 * 24 * time .Hour // 7 days or 604800 seconds
36+
37+ AmzPresignMaxExpires = 7 * 24 * time .Hour // 7 days or 604800 seconds
38+ AmzMaxClockSkew = 15 * time .Minute // Maximum allowed clock skew (15 minutes for AWS S3 compatibility)
3739
3840 v4AmzAlgorithm = "X-Amz-Algorithm"
3941 //nolint:gosec
@@ -378,11 +380,12 @@ func (ctx *verificationCtx) verifyExpiration() error {
378380 now := time .Now ().UTC ()
379381 timeDiff := now .Sub (requestTime )
380382
381- // Check for requests from the future and allow small clock skew
382- if timeDiff < 0 && timeDiff .Abs () > 5 * time . Minute {
383+ // Check for requests signed more than 15 minutes in the future (matches S3 behavior)
384+ if timeDiff < 0 && timeDiff .Abs () > AmzMaxClockSkew {
383385 return errors .ErrRequestNotReadyYet
384386 }
385387
388+ // Calculate expiration from the signed time, not current time
386389 expirationTime := requestTime .Add (time .Duration (ctx .AuthValue .Expires ) * time .Second )
387390 if now .After (expirationTime ) {
388391 return errors .ErrExpiredPresignRequest
You can’t perform that action at this time.
0 commit comments