Support authenticated proxies with separate settings for WebProxy, HttpClient credentials, and PreAuthentication#220
Conversation
Co-authored-by: philnach <[email protected]>
Co-authored-by: philnach <[email protected]>
|
@copilot can you make the one pr review change? |
Co-authored-by: philnach <[email protected]>
|
@copilot , we also want to support using the default credentials on the HttpClient that underlies the connection to CosmosDB. We will want to pass a httpclienthandler in for the httpclient. Something like the below. We need to not leak the httpclient and we need to re-use the httpclient so a new connection isn't created everytime and we run into connection exhaustion. var handler = new HttpClientHandler using var httpClient = new HttpClient(handler); |
Co-authored-by: philnach <[email protected]>
Implemented in commit a52dec4. Added a static |
|
@copilot, let's make it so there's 2 settings 1 for default credentials for the HttpClient and a different 1 for the proxy.. This way people can configure 1, both or neither. Let's also make the preauthentication configurable by the user. Make sure to update the README.MD to include the information about these new settings and specifically for the preauthentication that it can save on extra 401/407 responses, but should only be used if the endpoint is trusted. |
…ption Co-authored-by: philnach <[email protected]>
Implemented in commit 36c521f. Split into three separate settings:
README updated with security warning that PreAuthenticate can save extra 401/407 responses but should only be used when the endpoint is trusted. |
philnach
left a comment
There was a problem hiding this comment.
Change looks good to me.
markjbrown
left a comment
There was a problem hiding this comment.
This looks great! Thanks @philnach
Adds support for authenticated proxies when connecting to Cosmos DB with flexible configuration options. Users can configure proxy credentials, HttpClient credentials, and pre-authentication independently to resolve
407 Proxy Authentication Requirederrors.Changes Made
UseDefaultProxyCredentials(defaults tofalse) - Enables default credentials on the WebProxyUseDefaultCredentials(defaults tofalse) - Enables default credentials on the underlying HttpClientPreAuthenticate(defaults tofalse) - Sends credentials with the initial request rather than waiting for a 401/407 challengeWebProxy.UseDefaultCredentialswhenUseDefaultProxyCredentialsis enabledLazy<HttpClient>instances withHttpClientHandlerconfigured withCredentialCache.DefaultNetworkCredentialsfor HttpClient credential supportCosmosClientOptions.HttpClientFactorywhenUseDefaultCredentialsis enabledExtensions/Cosmos/README.mdandExampleConfigs.mdwith all new settings and security warnings for PreAuthenticateUsage
{ "ConnectionString": "AccountEndpoint=https://...", "Database": "myDb", "Container": "myContainer", "WebProxy": "http://yourproxy.server.com/", "UseDefaultProxyCredentials": true, "UseDefaultCredentials": true, "PreAuthenticate": true }Note:
PreAuthenticatecan save extra round-trips by avoiding 401/407 challenge responses, but should only be used when the endpoint is trusted.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.