Skip to content

Commit

Permalink
Merge pull request #366 from rdrawsky/master
Browse files Browse the repository at this point in the history
Support PLAIN SASL authentication mechansim
  • Loading branch information
postwait committed Oct 21, 2014
2 parents adcfa28 + bd245a7 commit 6489715
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/connection.js
Expand Up @@ -404,6 +404,21 @@ Connection.prototype._outboundHeartbeatTimerReset = function () {
}
};

Connection.prototype._saslResponse = function () {
var response;
if (this.options.authMechanism == 'AMQPLAIN')
response = {
LOGIN: this.options.login,
PASSWORD: this.options.password
};
else if (this.options.authMechanism == 'PLAIN')
response = "\0" + this.options.login + "\0" + this.options.password;
else
response = this.options.response;

return response;
}

Connection.prototype._onMethod = function (channel, method, args) {
debug && debug(channel + " > " + method.name + " " + JSON.stringify(args));

Expand Down Expand Up @@ -439,10 +454,7 @@ Connection.prototype._onMethod = function (channel, method, args) {
this._sendMethod(0, methods.connectionStartOk, {
clientProperties: this.options.clientProperties,
mechanism: this.options.authMechanism,
response: {
LOGIN: this.options.login,
PASSWORD: this.options.password
},
response: this._saslResponse(),
locale: 'en_US'
});
break;
Expand Down

0 comments on commit 6489715

Please sign in to comment.