Skip to content

Commit

Permalink
Fix/presigned url addressing style (#1179)
Browse files Browse the repository at this point in the history
* test

* test

* update

* add endpoint url to s3 client

* update version

* add more endpoint url
  • Loading branch information
mfshao authored Aug 29, 2024
1 parent cd66a72 commit 4cf044c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
login_required,
set_current_token,
validate_request,
JWTError,
)
from fence.config import config
from fence.errors import (
Expand Down Expand Up @@ -1096,13 +1095,15 @@ def get_signed_url(
region = flask.current_app.boto.get_bucket_region(
self.parsed_url.netloc, credential
)
endpoint_url = bucket.get("endpoint_url", None)
s3client = boto3.client(
"s3",
aws_access_key_id=credential["aws_access_key_id"],
aws_secret_access_key=credential["aws_secret_access_key"],
aws_session_token=credential.get("aws_session_token", None),
region_name=region,
config=Config(s3={"addressing_style": "path"}, signature_version="s3v4"),
endpoint_url=endpoint_url,
config=Config(signature_version="s3v4"),
)

cirrus_aws = AwsService(s3client)
Expand Down
8 changes: 7 additions & 1 deletion fence/blueprints/data/multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,19 @@ def generate_presigned_url_for_uploading_part(
presigned_url(str)
"""
try:
s3_buckets = get_value(
config, "S3_BUCKETS", InternalError("S3_BUCKETS not configured")
)
bucket = s3_buckets.get(bucket_name)
endpoint_url = bucket.get("endpoint_url", None)
s3client = boto3.client(
"s3",
aws_access_key_id=credentials["aws_access_key_id"],
aws_secret_access_key=credentials["aws_secret_access_key"],
aws_session_token=credentials.get("aws_session_token", None),
region_name=region,
config=Config(s3={"addressing_style": "path"}, signature_version="s3v4"),
endpoint_url=endpoint_url,
config=Config(signature_version="s3v4"),
)
cirrus_aws = AwsService(s3client)

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.3.0"
version = "10.3.1"
description = "Gen3 AuthN/AuthZ OIDC Service"
authors = ["CTDS UChicago <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 4cf044c

Please sign in to comment.