Skip to content

Commit

Permalink
fix(s3s/ops): allow presigned url requests with up to 15 minutes cloc…
Browse files Browse the repository at this point in the history
…k skew
  • Loading branch information
Nugine committed Nov 13, 2024
1 parent 5d3ec1f commit c53867c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/s3s/src/ops/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,16 @@ impl SignatureContext<'_> {
.ok_or_else(|| invalid_request!("invalid amz date"))?;

let duration = now - date;
if duration.is_positive().not() {
return Err(invalid_request!("invalid presigned url date"))?;

// Allow requests that are up to 15 minutes in the future.
// This is to account for clock skew between the client and server.
// See also https://github.com/minio/minio/blob/b5177993b371817699d3fa25685f54f88d8bfcce/cmd/signature-v4.go#L238-L242

// TODO: configurable max_skew_time

let max_skew_time = time::Duration::seconds(15 * 60);
if duration.is_negative() && duration.abs() > max_skew_time {
return Err(s3_error!(RequestTimeTooSkewed, "presigned url date is later than server time too much"));
}

if duration > presigned_url.expires {
Expand Down

0 comments on commit c53867c

Please sign in to comment.