Skip to content

Commit

Permalink
fix(auth): Fixed AUTHENTICATE LOGIN if server uses 'VXNlciBOYW1lAA=='…
Browse files Browse the repository at this point in the history
… for username
  • Loading branch information
andris9 committed Jan 8, 2025
1 parent 475ba24 commit 86c08a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/commands/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,22 @@ async function authLogin(connection, username, password) {
onPlusTag: async resp => {
if (resp.attributes && resp.attributes[0] && resp.attributes[0].type === 'TEXT') {
let question = Buffer.from(resp.attributes[0].value, 'base64').toString();
switch (question.toLowerCase().replace(/:$/, '')) {
case 'username': {
switch (
question.toLowerCase().replace(/[:\x00]*$/, '') // eslint-disable-line no-control-regex
) {
case 'username':
case 'user name': {
let encodedUsername = Buffer.from(username).toString('base64');
connection.log.debug({ src: 'c', msg: encodedUsername, comment: `Encoded username for AUTH=LOGIN` });
connection.write(encodedUsername);
break;
}

case 'password':
connection.log.debug({ src: 'c', msg: '(* value hidden *)', comment: `Encoded password for AUTH=LOGIN` });
connection.write(Buffer.from(password).toString('base64'));
break;

default: {
let error = new Error(`Unknown LOGIN question "${question}"`);
throw error;
Expand Down

0 comments on commit 86c08a7

Please sign in to comment.