How to access proxy user from inline script

Hi,
I’m running mitmdump with the nonanonymous flag enabled. I’m trying to get the value of the proxy username which is stored in the self.username variable that’s defined in the BasicProxyAuth class: https://github.com/mitmproxy/mitmproxy/blob/1dd078beb23aa0b483f945eed39c0136984f81a6/netlib/http/authentication.py#L76

I’ve tried tracing the code, and looking at the events available to inline scripts: http://docs.mitmproxy.org/en/v0.17/scripting/inlinescripts.html#events

I’ve tried looking at the clientconnect and request events, and I just haven’t been able to find the data I need.

Any help would be appreciated.

Hi @AnalogJ,

looks like there is indeed no good way to do this at the moment - we clean the headers here before passing the request to the inline script. I’d be happy to accept a PR that keeps the authentication at this place but moves the cleaning part below the process_request_hook call! :slight_smile: