Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
NodeJs can't authenticate over NTLM

We are using httpntlm (https://www.npmjs.com/package/httpntlm) library in order to authenticate with NTLM.

We are following the 3 steps of the protocol as example:

var ntlm = require('httpntlm').ntlm;
var async = require('async');
var httpreq = require('httpreq');
var HttpsAgent = require('agentkeepalive').HttpsAgent;
var keepaliveAgent = new HttpsAgent();

var options = {
    url: "https://someurl.com",
    username: 'm$',
    password: 'stinks',
    workstation: 'choose.something',
    domain: ''
};

async.waterfall([
function (callback){
    var type1msg = ntlm.createType1Message(options);

    httpreq.get(options.url, {
        headers:{
            'Connection' : 'keep-alive',
            'Authorization': type1msg
        },
        agent: keepaliveAgent
    }, callback);
},

function (res, callback){
    if(!res.headers['www-authenticate'])
        return callback(new Error('www-authenticate not found on response of second request'));

    var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
    var type3msg = ntlm.createType3Message(type2msg, options);

    setImmediate(function() {
        httpreq.get(options.url, {
            headers:{
                'Connection' : 'Close',
                'Authorization': type3msg
            },
            allowRedirects: false,
            agent: keepaliveAgent
        }, callback);
    });
}
], function (err, res) {
    if(err) return console.log(err);

    console.log(res.headers);
    console.log(res.body);
});

We get 401 in the first 2 calls, then the last one responses with 400 BadRequest. If I use Postman with NTLM authentication and I inspect the requests, the last call works and I get 200. (I've tried also axios-ntlm (https://www.npmjs.com/package/axios-ntlm) and I get the same error.

have you guys had this problem befor by any chance?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda