diff --git a/src/main/java/io/cryostat/ConfigProperties.java b/src/main/java/io/cryostat/ConfigProperties.java index 44796b81e..def299074 100644 --- a/src/main/java/io/cryostat/ConfigProperties.java +++ b/src/main/java/io/cryostat/ConfigProperties.java @@ -44,4 +44,6 @@ public class ConfigProperties { public static final String GRAFANA_DATASOURCE_URL = "grafana-datasource.url"; public static final String STORAGE_EXT_URL = "storage-ext.url"; + public static final String STORAGE_PRESIGNED_DOWNLOADS_ENABLED = + "storage.presigned-downloads.enabled"; } diff --git a/src/main/java/io/cryostat/recordings/Recordings.java b/src/main/java/io/cryostat/recordings/Recordings.java index 981033b72..c2aac50b5 100644 --- a/src/main/java/io/cryostat/recordings/Recordings.java +++ b/src/main/java/io/cryostat/recordings/Recordings.java @@ -138,6 +138,9 @@ public class Recordings { @ConfigProperty(name = ConfigProperties.GRAFANA_DATASOURCE_URL) Optional grafanaDatasourceURL; + @ConfigProperty(name = ConfigProperties.STORAGE_PRESIGNED_DOWNLOADS_ENABLED) + boolean presignedDownloadsEnabled; + @ConfigProperty(name = ConfigProperties.STORAGE_EXT_URL) Optional externalStorageUrl; @@ -959,7 +962,7 @@ public Map patchRecordingOptions( @Blocking @Path("/api/v3/activedownload/{id}") @RolesAllowed("read") - public Response createAndRedirectPresignedDownload(@RestPath long id) throws Exception { + public Response createAndRedirectDownload(@RestPath long id) throws Exception { ActiveRecording recording = ActiveRecording.findById(id); if (recording == null) { throw new NotFoundException(); @@ -992,8 +995,14 @@ public Response createAndRedirectPresignedDownload(@RestPath long id) throws Exc @Blocking @Path("/api/v3/download/{encodedKey}") @RolesAllowed("read") - public Response redirectPresignedDownload(@RestPath String encodedKey, @RestQuery String f) + public Response handleStorageDownload(@RestPath String encodedKey, @RestQuery String f) throws URISyntaxException { + if (!presignedDownloadsEnabled) { + return Response.status(RestResponse.Status.OK) + .entity(recordingHelper.getArchivedRecordingStream(encodedKey)) + .build(); + } + Pair pair = recordingHelper.decodedKey(encodedKey); logger.infov("Handling presigned download request for {0}", pair); GetObjectRequest getRequest = diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 35d882f37..ff0aa6b43 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -54,6 +54,7 @@ quarkus.http.filter.static.methods=GET quarkus.http.filter.static.order=1 storage-ext.url= +storage.presigned-downloads.enabled=false storage.buckets.archives.name=archivedrecordings storage.buckets.archives.expiration-label=expiration