diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/http-signature/lib')
-rw-r--r-- | deps/npm/node_modules/request/node_modules/http-signature/lib/parser.js | 27 | ||||
-rw-r--r-- | deps/npm/node_modules/request/node_modules/http-signature/lib/signer.js | 4 |
2 files changed, 15 insertions, 16 deletions
diff --git a/deps/npm/node_modules/request/node_modules/http-signature/lib/parser.js b/deps/npm/node_modules/request/node_modules/http-signature/lib/parser.js index 7c841b3171..5994a7e987 100644 --- a/deps/npm/node_modules/request/node_modules/http-signature/lib/parser.js +++ b/deps/npm/node_modules/request/node_modules/http-signature/lib/parser.js @@ -116,11 +116,14 @@ module.exports = { } assert.object(options, 'options'); assert.arrayOfString(options.headers, 'options.headers'); - assert.optionalNumber(options.clockSkew, 'options.clockSkew'); + assert.optionalFinite(options.clockSkew, 'options.clockSkew'); - if (!request.headers.authorization) - throw new MissingHeaderError('no authorization header present in ' + - 'the request'); + var authzHeaderName = options.authorizationHeaderName || 'authorization'; + + if (!request.headers[authzHeaderName]) { + throw new MissingHeaderError('no ' + authzHeaderName + ' header ' + + 'present in the request'); + } options.clockSkew = options.clockSkew || 300; @@ -134,18 +137,10 @@ module.exports = { var parsed = { scheme: '', params: {}, - signingString: '', - - get algorithm() { - return this.params.algorithm.toUpperCase(); - }, - - get keyId() { - return this.params.keyId; - } + signingString: '' }; - var authz = request.headers.authorization; + var authz = request.headers[authzHeaderName]; for (i = 0; i < authz.length; i++) { var c = authz.charAt(i); @@ -302,7 +297,7 @@ module.exports = { options.headers.forEach(function (hdr) { // Remember that we already checked any headers in the params // were in the request, so if this passes we're good. - if (parsed.params.headers.indexOf(hdr) < 0) + if (parsed.params.headers.indexOf(hdr.toLowerCase()) < 0) throw new MissingHeaderError(hdr + ' was not a signed header'); }); @@ -312,6 +307,8 @@ module.exports = { ' is not a supported algorithm'); } + parsed.algorithm = parsed.params.algorithm.toUpperCase(); + parsed.keyId = parsed.params.keyId; return parsed; } diff --git a/deps/npm/node_modules/request/node_modules/http-signature/lib/signer.js b/deps/npm/node_modules/request/node_modules/http-signature/lib/signer.js index ef9946f77c..deb5878679 100644 --- a/deps/npm/node_modules/request/node_modules/http-signature/lib/signer.js +++ b/deps/npm/node_modules/request/node_modules/http-signature/lib/signer.js @@ -387,7 +387,9 @@ module.exports = { assert.notStrictEqual(signature, '', 'empty signature produced'); } - request.setHeader('Authorization', sprintf(AUTHZ_FMT, + var authzHeaderName = options.authorizationHeaderName || 'Authorization'; + + request.setHeader(authzHeaderName, sprintf(AUTHZ_FMT, options.keyId, options.algorithm, options.headers.join(' '), |