Compare commits

...

1 Commits

Author SHA1 Message Date
Nicolas Humbert 93f2709413 proxy_host header 2021-11-08 10:39:14 +01:00
4 changed files with 21 additions and 9 deletions

View File

@ -14,6 +14,9 @@ function constructStringToSign(params) {
query, log, proxyPath } = params; query, log, proxyPath } = params;
const path = proxyPath || request.path; const path = proxyPath || request.path;
console.log('request.headers!!!', request.headers);
console.log('path!!!', path);
const canonicalReqResult = createCanonicalRequest({ const canonicalReqResult = createCanonicalRequest({
pHttpVerb: request.method, pHttpVerb: request.method,
pResource: path, pResource: path,

View File

@ -64,10 +64,18 @@ function createCanonicalRequest(params) {
signedHeadersList.sort((a, b) => a.localeCompare(b)); signedHeadersList.sort((a, b) => a.localeCompare(b));
const signedHeaders = signedHeadersList.join(';'); const signedHeaders = signedHeadersList.join(';');
console.log('pHeaders!!!', pHeaders);
console.log('pSignedHeaders!!!', pSignedHeaders);
const isProxyHost = !!pHeaders['proxyhost']
// canonical headers // canonical headers
const canonicalHeadersList = signedHeadersList.map(signedHeader => { const canonicalHeadersList = signedHeadersList.map(signedHeader => {
if (pHeaders[signedHeader] !== undefined) { if (pHeaders[signedHeader] !== undefined) {
const trimmedHeader = pHeaders[signedHeader] let header = pHeaders[signedHeader];
if (isProxyHost && signedHeader.toLowerCase() === 'host') {
header = pHeaders['proxyhost'];
}
const trimmedHeader = header
.trim().replace(/\s+/g, ' '); .trim().replace(/\s+/g, ' ');
return `${signedHeader}:${trimmedHeader}\n`; return `${signedHeader}:${trimmedHeader}\n`;
} }
@ -85,6 +93,7 @@ function createCanonicalRequest(params) {
const canonicalRequest = `${pHttpVerb}\n${canonicalURI}\n` + const canonicalRequest = `${pHttpVerb}\n${canonicalURI}\n` +
`${canonicalQueryStr}\n${canonicalHeaders}\n` + `${canonicalQueryStr}\n${canonicalHeaders}\n` +
`${signedHeaders}\n${payloadChecksum}`; `${signedHeaders}\n${payloadChecksum}`;
console.log('canonicalRequest!!!', canonicalRequest);
return canonicalRequest; return canonicalRequest;
} }

View File

@ -128,13 +128,13 @@ function check(request, log, data, awsService) {
} }
let proxyPath = null; let proxyPath = null;
if (request.headers.proxy_path) { if (request.headers.proxypath) {
try { try {
proxyPath = decodeURIComponent(request.headers.proxy_path); proxyPath = decodeURIComponent(request.headers.proxypath);
} catch (err) { } catch (err) {
log.debug('invalid proxy_path header', { proxyPath, err }); log.debug('invalid proxypath header', { proxyPath, err });
return { err: errors.InvalidArgument.customizeDescription( return { err: errors.InvalidArgument.customizeDescription(
'invalid proxy_path header') }; 'invalid proxypath header') };
} }
} }

View File

@ -63,13 +63,13 @@ function check(request, log, data) {
} }
let proxyPath = null; let proxyPath = null;
if (request.headers.proxy_path) { if (request.headers.proxypath) {
try { try {
proxyPath = decodeURIComponent(request.headers.proxy_path); proxyPath = decodeURIComponent(request.headers.proxypath);
} catch (err) { } catch (err) {
log.debug('invalid proxy_path header', { proxyPath }); log.debug('invalid proxypath header', { proxyPath });
return { err: errors.InvalidArgument.customizeDescription( return { err: errors.InvalidArgument.customizeDescription(
'invalid proxy_path header') }; 'invalid proxypath header') };
} }
} }