From 1e35cb780d16998078449cfd6966dc653c62fab4 Mon Sep 17 00:00:00 2001 From: Lucas van Beek Date: Tue, 13 Sep 2022 23:26:15 +0200 Subject: [PATCH] Fix partial success not passing when using agent authentication --- lib/client.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 80f372a8..ea1f99f0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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(); + }); + }); + } 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;