Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

S3 pre-signed URLs do not expire #1685

@sola91

Description

@sola91

I am using Localstack S3 in order to test that a link correctly expires after a given TimeToLive.
Here is a short scala snippet of what I am doing:

def createTemporaryLink(s3: AmazonS3, s3ObjectPath: String, temporaryLinkTtl: FiniteDuration): String = {
    val createdAt   = ZonedDateTime.now(ZoneOffset.UTC)
    val expiresAt   = Date.from(createdAt.plus(temporaryLinkTtl.asJava).toInstant)
    val amazonS3Uri = new AmazonS3URI(s3ObjectPath)
    val generatePresignedUrlRequest: GeneratePresignedUrlRequest =
      new GeneratePresignedUrlRequest(amazonS3Uri.getBucket, amazonS3Uri.getKey)
        .withMethod(HttpMethod.GET)
        .withExpiration(expiresAt)
    s3.generatePresignedUrl(generatePresignedUrlRequest).toString
  }

The code works and I get a valid link and I can even run an HTTP request and get the content of the file. However, the issue is that I can access the content of the s3 object even when the expirationTime has passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions