monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.51k stars 566 forks source link

Add HttpProxyAuthenticationProvider.authenticate(HttpRequest request) #198

Closed er1c closed 2 years ago

er1c commented 2 years ago

This should be binary compatible.

* Add HttpProxyAuthenticationProvider.authenticate(HttpRequest request)
* Add HttpProxyAuthenticationProvider.matches(HttpRequest request)
* Update test/AuthHttpProxyServer.java to include test

Motivation: I created a healthcheck intercept (https://gist.github.com/er1c/84a530af018f6c620421a9a20371d96e) and I want to have a different set (or none at all) of credentials that only apply to a specific uri (e.g. /status/health)

HttpProxyAuthenticationProvider.authenticate(HttpRequest) allows having different credentials based upon request properties (e.g. uri)

HttpProxyAuthenticationProvider.matches(HttpRequest) allows disabling authentication for specific request properties (e.g. uri)

This should also allow implementing a HttpProxyAuthenticationProvider that allows filtering based upon other properties in the HttpRequest (e.g. HeaderNames.AUTHORIZATION)

er1c commented 2 years ago

@monkeyWie I'll love you forever if you have a chance to review and possibly release this tomorrow 🙏🏻

monkeyWie commented 2 years ago

This look good!

er1c commented 2 years ago

@monkeyWie thank you for the release! I can confirm my healthcheck is now working nicely with 1.6.0, while still having proxy authorization for normal requests!