bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
54 stars 10 forks source link

Random 401 #88

Closed danbord closed 4 years ago

danbord commented 4 years ago

Hello,

I tried with many different versions, but I started to have weird behavior where I get some random 401 errors when running my UI test on my development computer. Those tests runs fine on our integration server, but locally some services often get a 401 but passes randomly too. Everything runs fine when I use the website.

I tried with cypress-ntlm-auth v1.3.0, 2.0.0m 2.0.1 and the latest 2.0.2. Same behavior.

I tried with cy.ntlmSso() and cy.ntlm() fucntions. Same behavior.

I tried with cypress 3.6.1, 3.5.0 and 3.4.1.

My 2 services are all running locally under IIS with localhost:8080 and localhost:8088. My angular web app is localhost:4200 with node (started with ng s -o).

Here is my debug log if it can help :

cypress:plugin:ntlm-auth SSO is supported +0ms cypress:plugin:ntlm-auth NTLM auth config API listening on port: 60221 +10ms cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 60222 +25ms cypress:plugin:ntlm-auth wrote C:\Users\Administrator\AppData\Roaming\cypress-ntlm-auth\cypress-ntlm-auth.port +4ms cypress:plugin:ntlm-auth Startup done! +1ms cypress:plugin:ntlm-auth { configApiUrl: 'http://127.0.0.1:60221', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:60222' } +1ms cypress:plugin:ntlm-auth Received alive +14s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60229 to target http://localhost:4200/ +6s cypress:plugin:ntlm-auth Request to http://localhost:4200/ - pass on +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60229 due to socket.close +10ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60242 to target http://127.0.0.1:60221/ +4s cypress:plugin:ntlm-auth Request to config API +2ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +13ms cypress:plugin:ntlm-auth Added new host http://localhost:80/ +1ms cypress:plugin:ntlm-auth Request to config API +18ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +2ms cypress:plugin:ntlm-auth Received valid NTLM config update +3ms cypress:plugin:ntlm-auth Added new host http://localhost:8088/ +1ms cypress:plugin:ntlm-auth Request to config API +10ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Added new host http://localhost:8080/ +1ms cypress:plugin:ntlm-auth Request to config API +22ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +2ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Added new host http://localhost:4200/ +0ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60247 to target http://localhost:4200/ +51ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +56ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60252 to target http://localhost:4200/ +7ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60253 to target http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +81ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +63ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +120ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60259 to target http://localhost:4200/ +68ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +4ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +534ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60259 due to socket.close +2s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60253 due to socket.close +7ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60252 due to socket.close +1ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60242 due to socket.close +0ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60247 due to socket.close +1ms cypress:plugin:ntlm-auth Received alive +1m cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60272 to target http://localhost:4200/ +6s cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60272 due to socket.close +3ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60285 to target http://127.0.0.1:60221/ +4s cypress:plugin:ntlm-auth Request to config API +2ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:80/ +2ms cypress:plugin:ntlm-auth Request to config API +22ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +2ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:8088/ +0ms cypress:plugin:ntlm-auth Request to config API +11ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:8080/ +0ms cypress:plugin:ntlm-auth Request to config API +10ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +6ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60290 to target http://localhost:4200/ +42ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +53ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60295 to target http://localhost:4200/ +8ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60296 to target http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +89ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +57ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +158ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60302 to target http://localhost:4200/ +30ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +483ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +4s cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +18ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +57ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +8ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60285 due to socket.close +2ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60305 to target http://localhost:4200/ +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +11ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +68ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +20ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +116ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60308 to target http://localhost:4200/ +14ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +265ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +2s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +100ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +231ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +4ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +1ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +0ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +28ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +3ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +10ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +3ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +431ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +350ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +9ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +4ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +1s cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +453ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +2ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +15ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8080/ +1s cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +820ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +3ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60296 due to socket.close +1s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60290 due to socket.close +941ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60305 due to socket.close +2s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +410ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +420ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +120ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +239ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +5s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +105ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +626ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +282ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +379ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +46ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +9ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +89ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +97ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60308 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60302 due to socket.close +149ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60356 to target http://localhost:8080/ +5s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +7ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60359 to target http://localhost:8088/ +7ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +8ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +3ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +8ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +28ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +5ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +1ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +5ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +5ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +25ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +220ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +3s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +14ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +690ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +98ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +20ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +109ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60356 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60359 due to socket.close +111ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60386 to target http://localhost:8080/ +5s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60389 to target http://localhost:8088/ +15ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +14ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +3ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +3ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +16ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +120ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +5ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +3ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +7ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +9ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +16ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +5ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +137ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +4s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +102ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +575ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +4ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +23ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +38ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60386 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60389 due to socket.close +64ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60412 to target http://localhost:8088/ +7s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +310ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +6ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +2ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +2ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +57ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +68ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60419 to target http://127.0.0.1:60221/ +386ms cypress:plugin:ntlm-auth Request to config API +1ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +2ms cypress:plugin:ntlm-auth Received valid NTLM config update +3ms cypress:plugin:ntlm-auth Updating host http://localhost:80/ +0ms cypress:plugin:ntlm-auth Request to config API +26ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +3ms cypress:plugin:ntlm-auth Received valid NTLM config update +3ms cypress:plugin:ntlm-auth Updating host http://localhost:8088/ +6ms cypress:plugin:ntlm-auth Request to config API +17ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:8080/ +1ms cypress:plugin:ntlm-auth Request to config API +18ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:60221/ +3ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Updating host http://localhost:4200/ +0ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60295 due to socket.close +10ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +22ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +436ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +7ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +8ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +24ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +29ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +19ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +155ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60437 to target http://localhost:4200/ +13ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +38ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +7ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +16ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +61ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +102ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +9ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60440 to target http://localhost:4200/ +4ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60441 to target http://localhost:4200/ +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60442 to target http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +8ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60443 to target http://localhost:8088/ +6ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +23ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +3ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +1ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +47ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60419 due to socket.close +486ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +673ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +208ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +4ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +2ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +2ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +14ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +71ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +440ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +11ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +4ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8080/ +15ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60443 due to socket.close +3s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60412 due to socket.close +1s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60441 due to socket.close +217ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60442 due to socket.close +98ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60440 due to socket.close +445ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:60462 to target http://localhost:8080/ +516ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +475ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +10ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +4ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8080/ +31ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +83ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60462 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:60437 due to socket.close +444ms

bjowes commented 4 years ago

Hi @danbord - first, big thanks for going the extra mile and testing your case with different versions of both the plugin and cypress before submitting!

It's a bit confusing because according to the logs, everything is fine. I see no indication of failed authentication (which would be the plausible cause for 401's being sent to the client).

How does those failed requests look in the browser? Can you see if they really go through the proxy?

Also - for how long has this been happening? What else might have changed in your environment, since it used to work fine for you?

danbord commented 4 years ago

Hello Bjorn, thanks again for your help. Heres 2 screenshots you can see what happens. Actually we are implementing cypress on another project, nothing is really different from the other one except that maybe we use more intensively two differnet api (8080 and 8088) for our rest calls

1 2

bjowes commented 4 years ago

Ok, that’s a bit clearer. If you could click on one of the requests in the cypress log details about the request are printed to the console log of the browser. Could you do that for a successful request and for a failing request, and try to compare the details?

If you want to post them here, please expand the details at least one level. I’m not sure what we are searching for so I need to see as much as possible.

danbord commented 4 years ago

Sure, here's the result of one OK (200) and one Not Authorized (401) for the /AccessRights endpoint.

By the way I made some more tests and if I remove all the calls to /usage/navigation in my code (which is on another website (localhost:8080), /AccessRights (which is on localhost:8088) is always working! Is it possible that cypress-ntlm-auth is mixing authentication between both webservice websites (localhost:8080 and localhost:8088 in my example)?

200 success


401 401

bjowes commented 4 years ago

Thanks - seeing the details of the 401 response you received narrowed down the possibilities in my code quite a bit. I have a feeling that this could be related to sockets staying open between tests. I don't think that the sockets are mixed up by ntlm-proxy, but I can see scenarios where the handshake won't be initiated if a previously authenticated socket is reused after a cy.ntlm() call has updated the config for the host.

Could you try adding a cy.ntlmReset() call in a beforeEach statement? The reset removes the current config, and it also purges all existing connections.

danbord commented 4 years ago

Well I’m only running one test so the cy.beforeEach is only called once. If you still think it’s relevant I’ll do the test tomorrow morning (I’m off work and cannot get access to my computer at the moment)

bjowes commented 4 years ago

Hmm, but in the logs you sent in the initial post I see that the NTLM host configurations are updated multiple times so I just assumed that was from multiple tests. Sure, that could occur within a single test too, but I would guess that isn't very common. Either way, try adding a cy.reset before you call cy.ntlm (given that you call cy.ntlm for all the hosts, otherwise you lose the config). No rush from my side, just trying to help you out :)

danbord commented 4 years ago

I added the cy.ntlmReset() just before my login fucntion in the beforeEach and it did not help :/

bjowes commented 4 years ago

Ok, thanks for trying. I think I will need to make a special build with extra logging for you to get to the bottom of this. How urgent is this issue for you?

One thing more to check:

danbord commented 4 years ago

Hey Bjorn, first of all, just thank you for helping me out. Understand that no matter how urgent this issue is for us, you support on you spare time, so please I don't want you to feel any pressure in any way! ;)

That issue is pretty annoying, and we must fix that in the coming week or so because we need those tests to work before we go in prod. In the meantime I can temporarily deactivate the "usage/navigation" calls to allow us to write tests locally though.

The AccessRights (which is a GET) seems to always be working when I type the url in a new tab (in same cypress context browser)

Here's a couple screenshots for XHR's:

/usage/navigation (POST on 8080) - 204 and 401 side by side image

/AccessRights (GET on 8088) - 200 and 401 side by side image

bjowes commented 4 years ago

What I'm looking for is a request to the API resulting in 401 without using ntlm-proxy. I need to know if your API returns a body in such a response (headers would also help) to determine which path the traffic passes through my proxy. There are some cases where the body is passed along as is, and other cases where the body is dropped.

To perform such a request, maybe it would be easier if you use a tool like Postman. Or simply reconfigure your local API to prevent access for your account, and use Chrome (without Cypress!) to access it. We need to avoid automatic authentication which Chrome will do for you if your own user has access to the API.

bjowes commented 4 years ago

Since we seem to be working in different timezones, here are a couple of modifications you can do to the cypress-ntlm-auth code to get better logging - if you can add these to the code in the node_modules folder where you are running cypress you can get the logs directly and I don't need to make a dedicated release (which I can't do until later). Please use plugin version 2.0.3 for the modifications.

In the file dist/proxy/ntlm.manager.js, line 128 - current code

if (authState === ntlm_state_enum_1.NtlmStateEnum.NotAuthenticated) {
  // NTLM auth failed (host may not support NTLM), just pass it through
  return callback();
}

change to

if (authState === ntlm_state_enum_1.NtlmStateEnum.NotAuthenticated) {
  // NTLM auth failed (host may not support NTLM), just pass it through
  this._debug.log('NTLM authentication failed, invalid state.');
  return callback();
}

In the file dist/proxy/ntlm.proxy.mitm.js, line 168 - current code

res.headers['connection'] = 'close';

change to

res.headers['connection'] = 'close';
self._debug.log('Received 401 from NTLM handshake, sending 401 with body to client. Client socket ' + ctx.clientToProxyRequest.socket.remoteAddress + ':' + ctx.clientToProxyRequest.socket.remotePort);

In the file dist/proxy/ntlm.proxy.mitm.js, line 184 - current code

ctx.proxyToClientResponse.end();

change to

ctx.proxyToClientResponse.end();
self._debug.log('No response in NTLM handshake callback, sending empty 401 to client. Client socket ' + ctx.clientToProxyRequest.socket.remoteAddress + ':' + ctx.clientToProxyRequest.socket.remotePort);

And then run your test with debug logs and submit them.

danbord commented 4 years ago

I updated my screenshots on my last post to be more readable.

Here's a 401 result for my AccessRights call with postman (since the desktop app of postman is not ntlm friendly I can get a 401 easily). By the way Body is empty when I get a 401

image

I'll update the code to add the logging like you asked :)

danbord commented 4 years ago

Here's the new logging as requested :

cypress:plugin:ntlm-auth SSO is supported +0ms cypress:plugin:ntlm-auth Existing proxy instance found, sending shutdown +5ms cypress:plugin:ntlm-auth Ports file deleted +21ms cypress:plugin:ntlm-auth NTLM auth config API listening on port: 63324 +6ms cypress:plugin:ntlm-auth NTLM auth proxy listening on port: 63325 +24ms cypress:plugin:ntlm-auth wrote C:\Users\Administrator\AppData\Roaming\cypress-ntlm-auth\cypress-ntlm-auth.port +3ms cypress:plugin:ntlm-auth Startup done! +0ms cypress:plugin:ntlm-auth { configApiUrl: 'http://127.0.0.1:63324', cypress:plugin:ntlm-auth ntlmProxyUrl: 'http://127.0.0.1:63325' } +0ms cypress:plugin:ntlm-auth Received alive +2s cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63346 to target http://localhost:4200/ +7s cypress:plugin:ntlm-auth Request to http://localhost:4200/ - pass on +0ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63346 due to socket.close +6ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63362 to target http://127.0.0.1:63324/ +4s cypress:plugin:ntlm-auth Request to config API +1ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:63324/ +0ms cypress:plugin:ntlm-auth Received valid NTLM config update +13ms cypress:plugin:ntlm-auth Added new host http://localhost:80/ +0ms cypress:plugin:ntlm-auth Request to config API +26ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:63324/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Added new host http://localhost:8088/ +0ms cypress:plugin:ntlm-auth Request to config API +24ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:63324/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +2ms cypress:plugin:ntlm-auth Added new host http://localhost:8080/ +1ms cypress:plugin:ntlm-auth Request to config API +16ms cypress:plugin:ntlm-auth Created untracked agent for target http://127.0.0.1:63324/ +1ms cypress:plugin:ntlm-auth Received valid NTLM config update +3ms cypress:plugin:ntlm-auth Added new host http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63367 to target http://localhost:4200/ +65ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +73ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63372 to target http://localhost:4200/ +4ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63373 to target http://localhost:4200/ +5ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +53ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +86ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +94ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +67ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +504ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63362 due to socket.close +4s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63373 due to socket.close +164ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +13ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +7ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +41ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63394 to target http://localhost:4200/ +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +18ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +14ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +83ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +107ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +13ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63396 to target http://localhost:4200/ +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63397 to target http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63398 to target http://localhost:4200/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63399 to target http://localhost:4200/ +3ms cypress:plugin:ntlm-auth Request to http://localhost:4200/ in registered NTLM Hosts +0ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +182ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +18ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +4ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +28ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +11ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +36ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +323ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +10ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +9ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +148ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +1s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +5ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +4ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +1ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +2ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +1ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +5ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +20ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +47ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +228ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +11ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +10ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +9ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +8ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8080/ +53ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63396 due to socket.close +3s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63398 due to socket.close +1s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63399 due to socket.close +36ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63397 due to socket.close +49ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63394 due to socket.close +300ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63372 due to socket.close +10ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63438 to target http://localhost:8080/ +792ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +12ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +357ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +18ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +7ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +7ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +79ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63443 to target http://localhost:8088/ +103ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +7ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +1ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +3ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +15ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +17ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +118ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +4s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +31ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +276ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +96ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +13ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +295ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +102ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +28ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +105ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63438 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63443 due to socket.close +175ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63483 to target http://localhost:8080/ +6s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +6ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63484 to target http://localhost:8088/ +1ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +4ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +6ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +23ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +117ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +13ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +2ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +2ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +7ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +10ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +5ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +145ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +4s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +8ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +772ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +2ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +38ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +94ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63484 due to socket.close +5s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63483 due to socket.close +118ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63535 to target http://localhost:8080/ +6s cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +13ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +110ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +9ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +2ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +2ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +14ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +50ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +97ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63546 to target http://localhost:8088/ +10ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +7ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +5ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +1ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +4ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +2ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +3ms cypress:plugin:ntlm-auth Created agent for client 127.0.0.1:63549 to target http://localhost:8080/ +7ms cypress:plugin:ntlm-auth Request to http://localhost:8080/ in registered NTLM Hosts +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8088/ +12ms cypress:plugin:ntlm-auth Received 401 with NTLM in www-authenticate header. Starting handshake. +11ms cypress:plugin:ntlm-auth Sending NTLM message type 1 +5ms cypress:plugin:ntlm-auth Received NTLM message type 2, using NTLMv2 +7ms cypress:plugin:ntlm-auth Sending NTLM message type 3 with initial client request +1ms cypress:plugin:ntlm-auth NTLM authentication successful for host http://localhost:8080/ +9ms cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +4s cypress:plugin:ntlm-auth Request to http://localhost:8088/ in registered NTLM Hosts +116ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63535 due to socket.close +1s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63367 due to socket.close +3s cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63549 due to socket.close +2ms cypress:plugin:ntlm-auth Removed agent for 127.0.0.1:63546 due to socket.close +0ms

danbord commented 4 years ago

By the way, I do not see anything in the log that we just added.

Just to be sure I was updating the right thing, I added a this._debug.log('NtlmManager constructor'); in the NtlmManager constructor and I see it in the log, so everything should be fine.

bjowes commented 4 years ago

Thanks! So, I think I know what the issue is. After studying the logs more closely it is clear that client sockets are reused for different targets. I didn't think clients behaved this way, and apparently the usually don't since the proxy usually works :) Could be related to a Chrome update.

Anyway, I have made a quick fix and published 2.0.4-beta.1 It's in beta until I have put together a few unit tests to cover this case, but it didn't break any of the existing tests so I think it's safe for you to use. Looking forward for your feedback

danbord commented 4 years ago

Björn you nailed it!!! :D Everything is working fine with the beta version!!! Thanks a bunch!

bjowes commented 4 years ago

That's great to hear! Thanks for providing all the debugging data. I'll prepare a proper release within a few days.

bjowes commented 4 years ago

Fixed in 2.0.4