Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix partial success not passing when using agent authentication #1215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,28 @@ class Client extends EventEmitter {
USERAUTH_FAILURE: (p, authMethods, partialSuccess) => {
if (curAuth.type === 'agent') {
const pos = curAuth.agentCtx.pos();
debug && debug(`Client: Agent key #${pos + 1} failed`);
return tryNextAgentKey();
if (partialSuccess) {
const key = curAuth.agentCtx.currentKey();
proto.authPK(curAuth.username, key, (buf, cb) => {
curAuth.agentCtx.sign(key, buf, {}, (err, signed) => {
if (err) {
err.level = 'agent';
this.emit('error', err);
} else {
return cb(signed);
}

return tryNextAgentKey();
});
});
Comment on lines +366 to +378

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucasvbeek is this actually needed? I'm cherry picking this PR and noticed that with this USERAUTH_FAILURE gets called again, just checking for partialSuccess seems enough and I can connect successfully.

if (!partialSuccess) {
      debug && debug(`Client: Agent key #${pos + 1} failed`);
      return tryNextAgentKey();
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it should be fine with just the check, I copied the full block from USERAUTH_PK_OK to make sure I didn't miss anything. Thanks for checking

} else {
debug && debug(`Client: Agent key #${pos + 1} failed`);
return tryNextAgentKey();
}
}

debug && debug(`Client: ${curAuth.type} auth failed`);
debug && debug(`Client: ${curAuth.type} auth ${partialSuccess
? 'succeeded with partial success' : 'failed'}`);

curPartial = partialSuccess;
curAuthsLeft = authMethods;
Expand Down