bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
55 stars 9 forks source link

Responsheaders get stripped from text - Proxy issue? #175

Closed mattiaskagstrom closed 3 years ago

mattiaskagstrom commented 3 years ago

Hi! Our server returns custom text along side the http response codes, but when it goes through the ntlm proxy, only the http response code is returned.

Response in Cypress: image

Response in normal chrome: image

bjowes commented 3 years ago

Interesting. I was unaware that it was possible to provide a custom status code response phrase. By just browsing through some docs, it seems that this is actually an optional feature - a client is not required to parse or display the response phrase. Hence I would not recommend relying on it.

For this plugin however, it seems like an easy fix. I'll put something together for you to try out.

mattiaskagstrom commented 3 years ago

a client is not required to parse or display the response phrase. Hence I would not recommend relying on it.

Awesome thanks! :) The application is running on an intranet so we control everything from the server to the clients browser version, so we can rely on things to be as expected :) But yes, I don't know why we haven't put the message in the response body. I haven't thought about it until i found this issue in our cypress tests :D

bjowes commented 3 years ago

Relased as 3.2.3-beta.1 Please give it a try and report back!

mattiaskagstrom commented 3 years ago

Same result :(

image

image

bjowes commented 3 years ago

Bummer! Could you specify in what context this request is being made? Does the endpoint use windows authentication or not? Is the 400 returned by the server before or after authentication?

This translates to differents points in my code where this may need to be handled. Part of it is handled by a third party library (http-mitm-proxy) so it could also be that the information is lost in there, or even within cypress.

On Thu, Jun 17, 2021 at 9:18 AM Mattias Kågström @.***> wrote:

Same result :(

[image: image] https://user-images.githubusercontent.com/3661126/122349672-bff68380-cf4c-11eb-9260-c6ade322e2f2.png

[image: image] https://user-images.githubusercontent.com/3661126/122349757-d69cda80-cf4c-11eb-90da-c50d3d35741f.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/175#issuecomment-862995088, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3AZDJ5KIZHGJBOSJETTTGOS3ANCNFSM46YW3QGQ .

mattiaskagstrom commented 3 years ago

It happens after authentication and is returned if the sent date is to early. image

Yes, the endpoint uses windows auth image

bjowes commented 3 years ago

Well, then it should be the very code that I patched. Could you attempt making a call using Postman (or similar) through the proxy? Start cypress-ntlm and find the proxy url in the settings in the UI, then perform the request with a Host header pointing to your target server. Note that the cy.ntlm command should have been performed first so the proxy is configured.

On Thu, Jun 17, 2021 at 10:16 AM Mattias Kågström @.***> wrote:

It happens after authentication and is returned if the sent date is to early. [image: image] https://user-images.githubusercontent.com/3661126/122358595-12d43900-cf55-11eb-9dd4-d18abf3d9bd0.png

Yes, the endpoint uses windows auth [image: image] https://user-images.githubusercontent.com/3661126/122358369-dd2f5000-cf54-11eb-9c9e-f3042e8158a7.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/175#issuecomment-863033425, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3E6ROGEAEXXCVV3K6TTTGVPTANCNFSM46YW3QGQ .

mattiaskagstrom commented 3 years ago

hmm, yeah, that actually seems to work. how strange..

image

bjowes commented 3 years ago

Not so strange actually, but a bit unfortunate. Cypress also acts as a proxy before the response reaches the browser, and apparently this information is lost in that process. Cypress is open source too so you can open an issue there, and even provide a patch. I would presume that this won't get high attention from the cypress developers, so doing it yourself is probably the only way to get this done quickly.

On Thu, Jun 17, 2021 at 10:42 AM Mattias Kågström @.***> wrote:

hmm, yeah, that actually seems to work. how strange..

[image: image] https://user-images.githubusercontent.com/3661126/122362681-9e9b9480-cf58-11eb-8684-cd4f2457faaa.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/175#issuecomment-863051356, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3EIT2J7L57SUWJLHF3TTGYN7ANCNFSM46YW3QGQ .

mattiaskagstrom commented 3 years ago

Will do! Thanks for all the help! :)