From 11e0a8d092befb8470369a2a017312b345a85d07 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Tue, 27 May 2014 11:22:17 +0200 Subject: [PATCH] Fixed binary credentials support. --- lib/authorizer.js | 6 ++++-- package.json | 2 +- test/abstract_server.js | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/authorizer.js b/lib/authorizer.js index 067cb01..d33e181 100644 --- a/lib/authorizer.js +++ b/lib/authorizer.js @@ -88,11 +88,13 @@ Authorizer.prototype._authenticate = function(client, user, pass, cb) { return; } + user = user.toString(); + client.user = user; user = this.users[user]; hasher({ - password: pass, + password: pass.toString(), salt: user.salt }, function(err, pass, salt, hash) { if (err) { @@ -132,7 +134,7 @@ Authorizer.prototype.addUser = function(user, pass, authorizePublish, } hasher({ - password: pass + password: pass.toString() }, function(err, pass, salt, hash) { if (!err) { that.users[user] = { diff --git a/package.json b/package.json index e638743..9ebf587 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "mongo-clean": "0.0.1" }, "dependencies": { - "mqtt": "~0.3.8", + "mqtt": "~0.3.9", "async": "~0.7.0", "ascoltatori": "~0.15.0", "commander": "~2.2.0", diff --git a/test/abstract_server.js b/test/abstract_server.js index ce43ac6..eac66fb 100644 --- a/test/abstract_server.js +++ b/test/abstract_server.js @@ -976,8 +976,8 @@ module.exports = function(moscaSettings, createConnection) { it("should support authentication (success)", function(done) { instance.authenticate = function(client, username, password, callback) { - expect(username).to.be.eql("matteo"); - expect(password).to.be.eql("collina"); + expect(username.toString()).to.be.eql("matteo"); + expect(password.toString()).to.be.eql("collina"); callback(null, true); }; @@ -998,8 +998,8 @@ module.exports = function(moscaSettings, createConnection) { it("should support authentication (failure)", function(done) { instance.authenticate = function(client, username, password, callback) { - expect(username).to.be.eql("matteo"); - expect(password).to.be.eql("collina"); + expect(username.toString()).to.be.eql("matteo"); + expect(password.toString()).to.be.eql("collina"); callback(null, false); };