joyent/node-triton#55 PUBAPI-1166 Use http-signature for generating Authorization, not sprintf

Reviewed by: Trent Mick <trent.mick@joyent.com>
This commit is contained in:
Alex Wilson 2015-11-13 16:19:35 -08:00
parent dfbbf309e9
commit 00cdb81287
3 changed files with 13 additions and 14 deletions

View File

@ -22,6 +22,8 @@
configuration. This command is still in development.
- `triton rbac {instance,image,network,package,}role-tags ...` to list
and manage role tags on each of those resources.
- #55 Update of smartdc-auth/sshpk deps, removal of duplicated code for
composing Authorization headers
## 2.1.4

View File

@ -40,6 +40,7 @@ var LOMStream = require('lomstream').LOMStream;
var os = require('os');
var querystring = require('querystring');
var vasync = require('vasync');
var auth = require('smartdc-auth');
var errors = require('./errors');
var SaferJsonClient = require('./SaferJsonClient');
@ -136,27 +137,23 @@ CloudApi.prototype._getAuthHeaders = function _getAuthHeaders(callback) {
var self = this;
var headers = {};
headers.date = new Date().toUTCString();
var sigstr = 'date: ' + headers.date;
var rs = auth.requestSigner({
sign: self.sign
});
headers.date = rs.writeDateHeader();
// TODO: token auth support
//if (this.token !== undefined) {
// obj.headers['X-Auth-Token'] = this.token;
//}
self.sign(sigstr, function (err, sig) {
if (err || !sig) {
rs.sign(function (err, authz) {
if (err || !authz) {
callback(new errors.SigningError(err));
return;
}
var ident = self.account;
if (self.user) {
ident += '/users/' + self.user;
}
headers.authorization = format(
'Signature keyId="/%s/keys/%s",algorithm="%s",signature="%s"',
ident, sig.keyId, sig.algorithm, sig.signature);
headers.authorization = authz;
callback(null, headers);
});
};

View File

@ -18,8 +18,8 @@
"read": "1.0.7",
"restify-clients": "1.1.0",
"restify-errors": "3.0.0",
"sshpk": "1.4.4",
"smartdc-auth": "2.1.7",
"sshpk": "1.6.x >=1.6.2",
"smartdc-auth": "2.2.3",
"strsplit": "1.0.0",
"tabula": "1.7.0",
"tilde-expansion": "0.0.0",