Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Fixed binary credentials support.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed May 27, 2014
1 parent 3ec3906 commit 11e0a8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/authorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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] = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions test/abstract_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand All @@ -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);
};

Expand Down

0 comments on commit 11e0a8d

Please sign in to comment.