Coder Social home page Coder Social logo

m0rtadelo / ntlm-client Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 339 KB

A node.js http(s) client that allows to request unprotected and protected content using `Basic`, `NTLM v1` or `NTLM v2` authentication methods without using any dependency, uses native `http` and `https` nodejs modules.

JavaScript 1.56% TypeScript 98.44%
node ntlm ntlm-authentication client

ntlm-client's People

Contributors

m0rtadelo avatar tleddx avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ntlm-client's Issues

The request wasn't resolved if response.on('end') was not fired

Somehow the event response.on('end') was not fired sometimes, so request was not resolved even the request already finished.

image

I think it'd be good if we can handle this case by handle when connection closed. Maybe by adding this.

response.on('close', () => {
  if (result.resolve) {
    delete result.resolve;
    res(result);
  }
});

How disable SSL certificate verify?

I use this code:

const client = new NtlmClient();
const ntlmData = await client.request({
    url: 'https://example.com/Menu',
    method: 'GET',
    debug: true,
    disableRedirect: false,
    insecureHTTPParser: false, // true, false or undefined do not affect error
    authMethod: ['ntlm'],
  },
  'USER',
  'PASSWORD',
);

And I get this error:

ntlm-client@m0rtadelo [request] init request
ntlm-client@m0rtadelo [setOptions] options setted!
ntlm-client@m0rtadelo [Fetch] request init for url: https://example.com/Menu
ntlm-client@m0rtadelo [Fetch] requesting (1/8) https://example.com/Menu
ntlm-client@m0rtadelo [setHeaders] headers = {}
ntlm-client@m0rtadelo [Fetch] error on request!
[Nest] 157  - 01/26/2023, 5:43:21 PM   ERROR [ExceptionsHandler] unable to get local issuer certificate
Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34)
    at TLSSocket.emit (node:events:527:28)
    at TLSSocket.emit (node:domain:475:12)
    at TLSSocket._finishInit (node:_tls_wrap:946:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:727:12)

But if I use curl with the -k option, which disables certificate verification, then I get the correct answer:

curl -X GET -k https://example.com/Menu --user "USER:PASSWORD" --ntlm

Usage in node 20

It works with node 20 and legacy MS Exchange 2013 if

  1. set node flags:

node --openssl-legacy-provider --tls-min-v1.1 --tls-ciphe
r-list=DEFAULT@SECLEVEL=0 main.js

  1. modify ntlm.ts: function: decodeType2Message

Replace
if (str.hasOwnProperty('headers') && str.headers.hasOwnProperty('www-authenticate'))

to

if ('headers' in str && str.headers.hasOwnProperty('www-authenticate'))

(It looks like 'headers' is inherited property now)

Thanks

Error when attempting get request with Node 18.7

I'm attempting to test the following call in my environment (updating the necessary fields):

const response = await client.request('http://ntlm.protected.data/items?id=26',
  'user', 'pass', 'workstation', 'domain'
);

When I make the call I get the following error:

Uncaught Error: error:0308010C:digital envelope routines::unsupported

Stepping through the stack trace the it appears the issue happens when a hash is being created for the password.

I've looked online and it seems like something changed with Node in version 17 that causes this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.