omjadas / hudsucker

Intercepting HTTP/S proxy
https://crates.io/crates/hudsucker
Apache License 2.0
206 stars 35 forks source link

How to parse Proxy-Authorization in HTTPS requests ? #123

Open 0x13A0F opened 1 month ago

0x13A0F commented 1 month ago

Hi I'm working on a proxy based on hudsucker, and im pretty new to Rust. the first thing i wanna do is make proxy authorization work, it does work fine with HTTP, but with HTTPS it's different, since there is a CONNECT request done first, so when the actual request go through, the header is dropped, is there anything builtin in hudsucker or Rust to handle this issue properly ?

omjadas commented 1 month ago

I think you will need to instead return a 407 in response to the CONNECT, rather than trying to do it in response to an HTTPS request.

0x13A0F commented 1 month ago

i don't get it, what's the point of returning 407 ? I made it work by checking if it's CONNECT then saving the proxy-authorization header. but somehow it doesn't work in the browser, the header is not there at all

omjadas commented 1 month ago

I assumed you would want to return a 407 if the client hasn't properly authenticated themselves. The browser won't include the proxy-authorization header for HTTPS requests because in a typical setup they would not be visible to a proxy server, which is why any checks you want to do should be on the CONNECT request.