Skip to content

Authentication method for Proxy in AzureResourceManager #36763

Open
@michalzimerman

Description

@michalzimerman

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

Metadata

Metadata

Labels

ARMMgmtThis issue is related to a management-plane library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions