Description
Problem:
In our application we would like to support costume-made authentication method (such as NTLM authentication) of the proxy server when using AzureResourceManger and ClientSecretCredential. Currently the ProxyOptions class allows only for basic authentication with username and password, but this is not always sufficient for our needs.
Desired Solutions:
In the com.microsoft.azure.management.Azure when configurating the client, we can set a Proxy and a ProxyAuthenticator.
This would be nice to have in AzureResourceManager as well. Either as part of the AzureResourceManager and ClientSecretCredential configuration, or as part of the ProxyOption class.
Alternative Solutions
What we are doing to bypass this, is to create an HttpClient with the relevant Authenticator, and set this https client to the AzureResourceManager and ClientSecretCredential objects.
Our costume ProxyAuthenticator is an internal class that implements okhttp3.Authenticator and overrides the authenticate(Route,Respose) method.
See code example below:
OkHttpClient httpClient = new OkHttpAsyncHttpClientBuilder(
new OkHttpClient.Builder().
proxy(proxy).
proxyAuthenticator(proxyAuthenticator).
build()).
build();
ClientSecretCredential credentials = new ClientSecretCredentialBuilder()
.clientId(clientId)
.clientSecret(clientSecretKey)
.tenantId(tenant)
.httpClient(httpClient)
.build();
azureResourceManager = AzureResourceManager
.configure()
.withLogLevel(HttpLogDetailLevel.BASIC)
.withHttpClient(httpClient)
.authenticate(credentials, profile)
.withSubscription(subId);
This solution requires us to use an additional dependency 'azure-core-http-okhttp'. This adds complexity to or dependency version management and will not be needed if we could configure the ProxyAuthenticator directly via the ProxyOptions or via the AzureResourceManger and ClientSecretCredential.
If any other information is needed or if you have an alternative solution for our issue, please contact me.
Thank you