From a3dc50fe1e4f914648b50d60a8e94ebd53cbef75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Tue, 9 Jul 2024 11:36:10 +0200 Subject: [PATCH] Replace presigned S3 URL with lambda request (#10456) - Closes #10419 --- .../Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso | 2 +- .../src/Enso_Cloud/Internal/Existing_Enso_Asset.enso | 7 ------- .../java/org/enso/base/enso_cloud/EnsoSecretReader.java | 4 ++-- .../src/main/java/org/enso/shttp/cloud_mock/CloudRoot.java | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso index 099125f4d5c..30cac40a640 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_File.enso @@ -224,7 +224,7 @@ type Enso_File asset = Existing_Enso_Asset.get_asset_reference_for self response = case asset.asset_type of Enso_Asset_Type.File -> - HTTP.fetch asset.get_download_url HTTP_Method.Get + Utils.http_request HTTP_Method.Get (asset.internal_uri + "/contents") Enso_Asset_Type.Data_Link -> Runtime.assert (open_options.contains Data_Link_Access.No_Follow) Utils.http_request HTTP_Method.Get asset.internal_uri diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Existing_Enso_Asset.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Existing_Enso_Asset.enso index 8c786aa0434..418484455c7 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Existing_Enso_Asset.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Existing_Enso_Asset.enso @@ -66,13 +66,6 @@ type Existing_Enso_Asset Panic.throw (Illegal_Argument.Error "`get_file_description` can only be called on File assets.") Utils.http_request_as_json HTTP_Method.Get self.internal_uri - ## PRIVATE - The returned URL may be valid only for a very short time, so it should not be - stored anywhere. - get_download_url self -> Text = - presigned_url = self.get_file_description |> get_required_field "url" expected_type=Text - presigned_url - ## PRIVATE Fetches the basic information about an existing file from the Cloud. It will fail if the file does not exist. diff --git a/std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretReader.java b/std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretReader.java index 408c9328706..9cd2f226d1f 100644 --- a/std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretReader.java +++ b/std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoSecretReader.java @@ -57,11 +57,11 @@ class EnsoSecretReader { } int status = response.statusCode(); - if (status == 401 || status == 403 || status >= 500) { + if (status == 401 || status >= 500) { if (retryCount < 0) { String kind = status >= 500 ? "server" : "authentication"; throw new IllegalArgumentException( - "Unable to read secret - numerous " + kind + " failures."); + "Unable to read secret - numerous " + kind + " failures (status code " + status + ")."); } else { // We forcibly refresh the access token and try again. AuthenticationProvider.getAuthenticationService().force_refresh(); diff --git a/tools/http-test-helper/src/main/java/org/enso/shttp/cloud_mock/CloudRoot.java b/tools/http-test-helper/src/main/java/org/enso/shttp/cloud_mock/CloudRoot.java index de227d37ff3..27124896f52 100644 --- a/tools/http-test-helper/src/main/java/org/enso/shttp/cloud_mock/CloudRoot.java +++ b/tools/http-test-helper/src/main/java/org/enso/shttp/cloud_mock/CloudRoot.java @@ -40,7 +40,6 @@ public class CloudRoot extends HandlerWithTokenAuth { boolean isValidButExpired = token.equals("TEST-EXPIRED-TOKEN-beef"); if (isValidButExpired) { expiredTokensCounter.registerExpiredTokenFailure(); - return 403; } return 401;