Replace presigned S3 URL with lambda request (#10456)

- Closes #10419
This commit is contained in:
Radosław Waśko 2024-07-09 11:36:10 +02:00 committed by GitHub
parent 4b3e4ae15e
commit a3dc50fe1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 11 deletions

View File

@ -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

View File

@ -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.

View File

@ -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();

View File

@ -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;