Skip to content

Commit

Permalink
Deploy consortia tab of AnVIL portal (#5452, PR #5453)
Browse files Browse the repository at this point in the history
  • Loading branch information
achave11-ucsc committed Aug 4, 2023
2 parents 65f7ff0 + de1ed6f commit 2756afa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
6 changes: 6 additions & 0 deletions deployments/anvildev.browser/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def env() -> Mapping[str, Optional[str]]:
'bucket': 'portal',
'tarball_path': 'public',
'real_path': ''
},
'consortia': {
'domain': '{AZUL_DOMAIN_NAME}',
'bucket': 'consortia',
'tarball_path': 'out',
'real_path': ''
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions deployments/anvilprod.browser/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def env() -> Mapping[str, Optional[str]]:
'bucket': 'portal',
'tarball_path': 'public',
'real_path': ''
},
'consortia': {
'domain': '{AZUL_DOMAIN_NAME}',
'bucket': 'consortia',
'tarball_path': 'out',
'real_path': ''
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions terraform/browser/browser.tf.json.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
)

buckets = {
bucket: aws.qualified_bucket_name(bucket)
for bucket in ['portal', 'browser']
site['bucket']: aws.qualified_bucket_name(site['bucket'])
for project, branches in config.browser_sites.items()
for branch, sites in branches.items()
for site_name, site in sites.items()
}


Expand Down Expand Up @@ -135,6 +137,13 @@ def emit():
explorer_domain_router=True,
add_response_security_headers=False),
google_search_behavior(),
*(
bucket_behaviour('consortia',
path_pattern=path_pattern,
ptm_next_path_mapper=True,
ptm_add_response_headers=False)
for path_pattern in ['/consortia*', '_next/*']
),
],
'default_cache_behavior':
bucket_behaviour('portal',
Expand Down
15 changes: 15 additions & 0 deletions terraform/browser/ptm_add_response_headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function handler(event) {
var response = event.response;
var headers = response.headers;

// Set HTTP security headers
// Since JavaScript doesn't allow for hyphens in variable names, we use the dict["key"] notation
headers['strict-transport-security'] = { value: 'max-age=63072000; includeSubdomains; preload'};
// headers['content-security-policy'] = { value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'"};
// headers['x-content-type-options'] = { value: 'nosniff'};
// headers['x-frame-options'] = {value: 'DENY'};
// headers['x-xss-protection'] = {value: '1; mode=block'};

// Return the response to viewers
return response;
}
22 changes: 22 additions & 0 deletions terraform/browser/ptm_next_path_mapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function handler(event) {

var request = event.request;

var uri = request.uri;


if(uri.includes(".")){
// is a request for a file , leaeve alone
return request;
}

if(uri.endsWith("/")){
//this was a request for for something like /explore/files/ remove the trailing /
request.uri = request.uri.slice(0, -1);
}

// final case add .html as this was not a file /explore or /explore/
request.uri +=".html";

return request;
}

0 comments on commit 2756afa

Please sign in to comment.