Skip to content

Commit

Permalink
Fix/bucket name (uc-cdis#1193)
Browse files Browse the repository at this point in the history
* fix use real bucket name

* fix

* update comment

* use regex

* update version
  • Loading branch information
mfshao authored Oct 28, 2024
1 parent 5dd3c75 commit 37c3da5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,11 @@ def get_signed_url(

bucket_name = self.bucket_name()
bucket = s3_buckets.get(bucket_name)
# special handling for bucket names from fence config may contain not allowed characters (e.g.: wildcards)
# in this case, use indexd url to determine bucket name
real_bucket_name = bucket_name
if real_bucket_name and not re.match("^[a-z0-9-.]{3,63}$", real_bucket_name):
real_bucket_name = self.parsed_url.netloc

object_id = self.parsed_url.path.strip("/")

Expand Down Expand Up @@ -1114,7 +1119,7 @@ def get_signed_url(
# get presigned url for upload
if action == "PUT":
url = cirrus_aws.upload_presigned_url(
bucket_name, object_id, expires_in, None
real_bucket_name, object_id, expires_in, None
)
# get presigned url for download
else:
Expand All @@ -1123,11 +1128,11 @@ def get_signed_url(
# https://github.com/boto/boto3/issues/3685
auth_info["x-amz-request-payer"] = "requester"
url = cirrus_aws.requester_pays_download_presigned_url(
bucket_name, object_id, expires_in, auth_info
real_bucket_name, object_id, expires_in, auth_info
)
else:
url = cirrus_aws.download_presigned_url(
bucket_name, object_id, expires_in, auth_info
real_bucket_name, object_id, expires_in, auth_info
)

return url
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fence"
version = "10.4.0"
version = "10.4.1"
description = "Gen3 AuthN/AuthZ OIDC Service"
authors = ["CTDS UChicago <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 37c3da5

Please sign in to comment.