Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/internal-gateway/files/conf.d/s3-gateway.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ server {
proxy_read_timeout 60s;
proxy_send_timeout 60s;

js_set $auth_header auth.setAuthHeader;

proxy_set_header Authorization $auth_header;

proxy_pass http://{{ index $vals "codefresh" "serviceEndpoints" "cfapi-auth" "svc" }}:{{ index $vals "codefresh" "serviceEndpoints" "cfapi-auth" "port" }};
}
}
16 changes: 14 additions & 2 deletions charts/internal-gateway/files/njs/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ function account_name(r) {
const auth_entity = r.variables["auth_entity"];
const b64decoded = Buffer.from(auth_entity, 'base64');
const json = JSON.parse(b64decoded);
const account_name = json.authenticatedEntity.activeAccount.name;
const account_name = json.activeAccount.name;

return account_name;
}

export default {account_name};
function setAuthHeader(r) {
let auth = r.headersIn['authorization'];
if (auth) {
// Look for the pattern: Credential=<value>/...
let matches = auth.match(/Credential=([^\/]+)\//);
if (matches && matches.length > 1) {
return matches[1];
}
}
return "";
}

export default { account_name, setAuthHeader };