mrbbot / ntlm

🔐 NTLM authentication for Dart/Flutter.
https://pub.dev/packages/ntlm
The Unlicense
14 stars 15 forks source link

Exception: Connection closed before full header was received #16

Open albatrosify opened 3 years ago

albatrosify commented 3 years ago

Hello,

I am trying to include NTLM Authentication for InAppWebView for the intranet of my company. However when I create a new NTLMClient and direct it to out 401 Unauthorized page, I am getting multiple excpetions starting with Connection closed before full header was received.

Do you have any idea what I can do to fix this?

A simple http.get with same cookies and url, gets me the 401 Unauthroized page.

mrbbot commented 3 years ago

Hello. 👋 Please could you provide me with the following information:

Thanks!

albatrosify commented 3 years ago

Hello Mrbbot,

thanks for your quick answer: I am happy to answer with the following details:

One question: Is there a way to "hijack" a NTLM Session and use it in inappwebview? I would need to continue in inappwebview after ntlm logon.

I can only provide you with screenshots on how the error processes: In order: image image image image

mrbbot commented 3 years ago

Hmmm ok, it looks like this is an open issue in the main Flutter repository (https://github.com/flutter/flutter/issues/41573) for which there doesn't seem to be an easy fix. What device are you trying to run this code on? Physical or Emulator/Simulator? Android or iOS?

With regards to inappwebview, the NTLM authentication implemented by this library is stateless and has no concept of sessions. You need to send NTLM credentials each time you make a request. However, if your web server returned a session cookie on the initial request, you may be able to extract that from the response headers and store this using the CookieManager class. I'm not that familiar with IIS but this article (https://techcommunity.microsoft.com/t5/iis-support-blog/request-based-versus-session-based-kerberos-authentication-or/ba-p/916043) looks interesting, especially the section on "How to change AuthPersistNonNTLM setting to True, to make Windows Authentication Session-Based?".