Skip to content

Commit 7eeda3e

Browse files
authored
fix(presign): remove baseUri property to allow for S3 virtual hosts style access (#405)
1 parent 9cbbef3 commit 7eeda3e

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

src/main/java/io/cryostat/reports/PresignedFormData.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515
*/
1616
package io.cryostat.reports;
1717

18+
import java.net.URI;
19+
1820
import jakarta.ws.rs.core.MediaType;
1921
import org.jboss.resteasy.reactive.PartType;
2022
import org.jboss.resteasy.reactive.RestForm;
2123

2224
public class PresignedFormData {
2325
@RestForm
2426
@PartType(MediaType.TEXT_PLAIN)
25-
public String path;
26-
27-
@RestForm
28-
@PartType(MediaType.TEXT_PLAIN)
29-
public String query;
27+
public URI uri;
3028

3129
@RestForm
3230
@PartType(MediaType.TEXT_PLAIN)

src/main/java/io/cryostat/reports/ReportResource.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.IOException;
2020
import java.io.InputStream;
2121
import java.net.HttpURLConnection;
22-
import java.net.URI;
2322
import java.net.URISyntaxException;
2423
import java.nio.file.Files;
2524
import java.nio.file.StandardCopyOption;
@@ -66,7 +65,6 @@
6665
import jakarta.ws.rs.ServerErrorException;
6766
import jakarta.ws.rs.core.MediaType;
6867
import jakarta.ws.rs.core.Response;
69-
import jakarta.ws.rs.core.UriBuilder;
7068
import org.apache.commons.lang3.StringUtils;
7169
import org.apache.commons.lang3.tuple.Pair;
7270
import org.eclipse.microprofile.config.inject.ConfigProperty;
@@ -87,9 +85,6 @@ public class ReportResource {
8785
@ConfigProperty(name = "io.cryostat.reports.timeout", defaultValue = "29000")
8886
String timeoutMs;
8987

90-
@ConfigProperty(name = "cryostat.storage.base-uri")
91-
Optional<String> storageBase;
92-
9388
@ConfigProperty(name = "cryostat.storage.auth-method")
9489
Optional<String> storageAuthMethod;
9590

@@ -154,21 +149,8 @@ public String getReportFromPresigned(RoutingContext ctx, @BeanParam PresignedFor
154149
long timeout = TimeUnit.MILLISECONDS.toNanos(Long.parseLong(timeoutMs));
155150
long start = System.nanoTime();
156151

157-
if (storageBase.isEmpty()) {
158-
logger.error(
159-
"Configuration property \"cryostat.storage.base-uri\" is unset, cannot handle"
160-
+ " presigned report requests!");
161-
throw new ServerErrorException(Response.Status.BAD_GATEWAY);
162-
}
163-
164-
UriBuilder uriBuilder =
165-
UriBuilder.newInstance()
166-
.uri(new URI(storageBase.get()))
167-
.path(form.path)
168-
.replaceQuery(form.query);
169-
URI downloadUri = uriBuilder.build();
170-
logger.debugv("Attempting to download presigned recording from {0}", downloadUri);
171-
HttpURLConnection httpConn = (HttpURLConnection) downloadUri.toURL().openConnection();
152+
logger.debugv("Attempting to download presigned recording from {0}", form.uri);
153+
HttpURLConnection httpConn = (HttpURLConnection) form.uri.toURL().openConnection();
172154
httpConn.setRequestMethod("GET");
173155
if (httpConn instanceof HttpsURLConnection) {
174156
HttpsURLConnection httpsConn = (HttpsURLConnection) httpConn;

src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ quarkus.native.additional-build-args =\
1414
-H:ResourceConfigurationFiles=resource-config.json,\
1515
-H:ReflectionConfigurationFiles=reflect-config.json
1616

17-
cryostat.storage.base-uri=
1817
cryostat.storage.auth-method=
1918
cryostat.storage.auth=
2019
cryostat.storage.tls-version=TLSv1.2

0 commit comments

Comments
 (0)