Blame view

app/services/SshAuthServ.js 557 Bytes
51adb054   Geoffrey PREUD'HOMME   Authentification ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  var Client = require('ssh2').Client;
  
  var creds = require('../../config/sshAuth');
  
  var SshAuth = {};
  
  SshAuth.verify = function (login, pass, cb) {
      var conn = new Client();
      conn.on('ready', function () {
          cb(null, true);
      }).on('error', function(err) {
          if (err.level === 'client-authentication') {
              cb(null, false);
          } else {
              cb(err);
          }
      }).connect({
          host: creds.host,
          port: creds.port,
          username: login,
          password: pass
      });
  };
  
  module.exports = SshAuth;