SamDecrock / node-http-ntlm

Node.js module to authenticate using HTTP NTLM
MIT License
192 stars 89 forks source link

Storing Cookies & Keeping Session Alive #58

Closed shanewignall closed 7 years ago

shanewignall commented 7 years ago

This module seems to be properly going through the NTLM handshake, but I'm unsure of how to store the site's authentication cookie and keep the session alive to actually interact with the website.

Perhaps I just don't understand the intended workflow in which to incorporate this module into. What I want to do:

  1. Authenticate with website
  2. Save a security cookie generated upon handshake completion for future requests
  3. Make requests with request (https://github.com/request/request) using the cookie

Am I going about it the wrong way?

SamDecrock commented 7 years ago

I fear that every request needs to contain some kind of NTLM handshake, I'm not sure.

I should Wireshark a real browser - server connection to see what's going on in the following requests.

shanewignall commented 7 years ago

A log-in request in an actual browser produces an ASP.NET_SessionId cookie. Would I be incorrect in assuming that I should be able to store that cookie after authentication to use in subsequent requests within the same session?

If so.. is it possible to pull that cookie information with node-http-ntlm?

SamDecrock commented 7 years ago

sure, cookies are stored in the res-object. It could be that ASP.NET also uses some kind of viewstate POST-variable that you need to pass on, I'm not sure.

shanewignall commented 7 years ago

Ah, I think the reason I was confused was because the cookie is being generated in a different request than the one I've been looking with.

Thanks for the help - love this module!

revolunet commented 6 years ago

Hi @shanewignall, did you find a way to reuse the cookie provided by http-ntlm ?

shanewignall commented 6 years ago

@revolunet No, I wasn't able to figure that out.. I ended up not needing to perform this task. Sorry!

revolunet commented 6 years ago

Thanks for answering !