Merge pull request #15 from isocolsky/http_method
add http method to request signature
This commit is contained in:
commit
864b45f098
2
app.js
2
app.js
|
@ -83,7 +83,7 @@ function getServerWithAuth(req, res, cb) {
|
|||
var credentials = getCredentials(req);
|
||||
var auth = {
|
||||
copayerId: credentials.copayerId,
|
||||
message: req.url + '|' + JSON.stringify(req.body),
|
||||
message: req.method.toLowerCase() + '|' + req.url + '|' + JSON.stringify(req.body),
|
||||
signature: credentials.signature,
|
||||
};
|
||||
CopayServer.getInstanceWithAuth(auth, function(err, server) {
|
||||
|
|
|
@ -38,8 +38,8 @@ function _parseError(body) {
|
|||
log.error(code, message);
|
||||
};
|
||||
|
||||
function _signRequest(url, args, privKey) {
|
||||
var message = url + '|' + JSON.stringify(args);
|
||||
function _signRequest(method, url, args, privKey) {
|
||||
var message = method.toLowerCase() + '|' + url + '|' + JSON.stringify(args);
|
||||
return SignUtils.sign(message, privKey);
|
||||
};
|
||||
|
||||
|
@ -84,15 +84,15 @@ ClientLib.prototype._loadAndCheck = function() {
|
|||
return data;
|
||||
};
|
||||
|
||||
ClientLib.prototype._doRequest = function(type, url, args, data, cb) {
|
||||
var reqSignature = _signRequest(url, args, data.signingPrivKey);
|
||||
ClientLib.prototype._doRequest = function(method, url, args, data, cb) {
|
||||
var reqSignature = _signRequest(method, url, args, data.signingPrivKey);
|
||||
var absUrl = _getUrl(url);
|
||||
request({
|
||||
headers: {
|
||||
'x-identity': data.copayerId,
|
||||
'x-signature': reqSignature,
|
||||
},
|
||||
method: type,
|
||||
method: method,
|
||||
url: absUrl,
|
||||
body: args,
|
||||
json: true,
|
||||
|
|
Loading…
Reference in New Issue