MCPcopy Create free account
hub / github.com/mscdex/ssh2 / doNextAuth

Method doNextAuth

lib/client.js:857–1068  ·  view source on GitHub ↗
(nextAuth)

Source from the content-addressed store, hash-verified

855
856 let hasSentAuth = false;
857 const doNextAuth = (nextAuth) => {
858 if (hasSentAuth)
859 return;
860 hasSentAuth = true;
861
862 if (nextAuth === false) {
863 const err = new Error('All configured authentication methods failed');
864 err.level = 'client-authentication';
865 this.emit('error', err);
866 this.end();
867 return;
868 }
869
870 if (typeof nextAuth === 'string') {
871 // Remain backwards compatible with original `authHandler()` usage,
872 // which only supported passing names of next method to try using data
873 // from the `connect()` config object
874
875 const type = nextAuth;
876 if (authsAllowed.indexOf(type) === -1)
877 return skipAuth(`Authentication method not allowed: ${type}`);
878
879 const username = this.config.username;
880 switch (type) {
881 case 'password':
882 nextAuth = { type, username, password: this.config.password };
883 break;
884 case 'publickey':
885 nextAuth = { type, username, key: privateKey };
886 break;
887 case 'hostbased':
888 nextAuth = {
889 type,
890 username,
891 key: privateKey,
892 localHostname: this.config.localHostname,
893 localUsername: this.config.localUsername,
894 };
895 break;
896 case 'agent':
897 nextAuth = {
898 type,
899 username,
900 agentCtx: new AgentContext(this._agent),
901 };
902 break;
903 case 'keyboard-interactive':
904 nextAuth = {
905 type,
906 username,
907 prompt: (...args) => this.emit('keyboard-interactive', ...args),
908 };
909 break;
910 case 'none':
911 nextAuth = { type, username };
912 break;
913 default:
914 return skipAuth(

Callers

nothing calls this directly

Calls 12

endMethod · 0.95
parseKeyFunction · 0.85
createAgentFunction · 0.85
isAgentFunction · 0.85
getKeyAlgosFunction · 0.85
authPasswordMethod · 0.80
authPKMethod · 0.80
authHostbasedMethod · 0.80
initMethod · 0.80
authKeyboardMethod · 0.80
authNoneMethod · 0.80
signMethod · 0.45

Tested by

no test coverage detected