Skip to content

Commit

Permalink
Merge 1062432 into d3ce3bc
Browse files Browse the repository at this point in the history
  • Loading branch information
Avantol13 committed Mar 10, 2020
2 parents d3ce3bc + 1062432 commit 374919e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Fence
# Fence

[![Build Status](https://travis-ci.org/uc-cdis/fence.svg?branch=master)](https://travis-ci.org/uc-cdis/fence)

Expand Down
19 changes: 15 additions & 4 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,24 @@ def get_signed_url(
aws_creds = get_value(
config, "AWS_CREDENTIALS", InternalError("credentials not configured")
)

http_url = "https://{}.s3.amazonaws.com/{}".format(
self.parsed_url.netloc, self.parsed_url.path.strip("/")
s3_buckets = get_value(
config, "S3_BUCKETS", InternalError("buckets not configured")
)

bucket_name = self.bucket_name()
bucket = s3_buckets.get(bucket_name)

if bucket and bucket.get("endpoint_url"):
http_url = bucket["endpoint_url"].strip("/") + "/{}/{}".format(
self.parsed_url.netloc, self.parsed_url.path.strip("/")
)
else:
http_url = "https://{}.s3.amazonaws.com/{}".format(
self.parsed_url.netloc, self.parsed_url.path.strip("/")
)

credential = S3IndexedFileLocation.get_credential_to_access_bucket(
self.bucket_name(), aws_creds, expires_in
bucket_name, aws_creds, expires_in
)

# if it's public and we don't need to force the signed url, just return the raw
Expand Down
2 changes: 2 additions & 0 deletions fence/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ S3_BUCKETS: {}
# bucket1:
# cred: 'CRED1'
# region: 'us-east-1'
# # optionally you can manually specify an s3-compliant endpoint for this bucket
# endpoint_url: 'https://cleversafe.example.com/'
# bucket2:
# cred: 'CRED2'
# region: 'us-east-1'
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ def indexd_client(app, request):
"baseid": "",
"rev": "",
"size": 10,
"file_name": "file1",
"urls": ["s3://bucket1/key"],
"file_name": "file2",
"urls": ["s3://bucket2/key"],
"hashes": {},
"acl": ["phs000178", "phs000218"],
"form": "",
Expand Down
1 change: 1 addition & 0 deletions tests/test-fence-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ S3_BUCKETS:
cred: 'CRED1'
bucket2:
cred: 'CRED2'
endpoint_url: 'https://cleversafe.example.com/'
region: 'us-east-1'
bucket3:
cred: 'CRED1'
Expand Down

0 comments on commit 374919e

Please sign in to comment.