Skip to content

Commit b9340a1

Browse files
authored
Added STS Endpoint Variable
1 parent 7ee7d5a commit b9340a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

common/etc/nginx/include/s3gateway.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,12 @@ function redirectToS3(r) {
405405
var isDirectoryListing = allow_listing && _isDirectory(uriPath);
406406

407407
if (isDirectoryListing && r.method === 'GET') {
408+
_debug_log(r, 'Redirecting to S3Listing..')
408409
r.internalRedirect("@s3Listing");
409410
} else if (!isDirectoryListing && uriPath === '/') {
410411
r.internalRedirect("@error404");
411412
} else {
413+
_debug_log(r, 'Redirecting to S3..')
412414
r.internalRedirect("@s3");
413415
}
414416
}
@@ -1013,11 +1015,12 @@ async function _fetchEC2RoleCredentials() {
10131015
async function _fetchWebIdentityCredentials(r) {
10141016
var arn = process.env['AWS_ROLE_ARN'];
10151017
var name = process.env['HOSTNAME'] || 'nginx-s3-gateway';
1018+
var sts_endpoint = process.env['STS_ENDPOINT'] || 'https://sts.amazonaws.com';
10161019
var token = fs.readFileSync(process.env['AWS_WEB_IDENTITY_TOKEN_FILE']);
10171020

10181021
var params = "Version=2011-06-15&Action=AssumeRoleWithWebIdentity&RoleArn=" + arn + "&RoleSessionName=" + name + "&WebIdentityToken=" + token;
10191022

1020-
var response = await ngx.fetch("https://sts.us-east-1.amazonaws.com?" + params, {
1023+
var response = await ngx.fetch(sts_endpoint + "?" + params, {
10211024
headers: {
10221025
"Accept": "application/json"
10231026
},

0 commit comments

Comments
 (0)