Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Proxy authentication not set correctly in ServiceBusClientBuilder #24230

Closed
3 tasks
ram-itzme opened this issue Sep 21, 2021 · 8 comments · Fixed by #31832
Closed
3 tasks

[BUG] - Proxy authentication not set correctly in ServiceBusClientBuilder #24230

ram-itzme opened this issue Sep 21, 2021 · 8 comments · Fixed by #31832
Assignees
Labels
Azure.Core azure-core bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs Service Bus
Milestone

Comments

@ram-itzme
Copy link

ram-itzme commented Sep 21, 2021

Describe the bug
When service bus client is created from the apps behind corporate proxy, the proxy authentication fails because the authentication type always defaults to NONE.

This results in the client connection failure

Exception or Stack Trace
2021-09-21 21:04:17.499 ERROR 4464 --- [ctor-executor-1] c.m.a.p.transport.proxy.impl.ProxyImpl : Proxy authentication required. User configured: 'NONE', but supported proxy authentication methods are: BASIC

To Reproduce
Configure HTTP_PROXY, HTTPS_PROXY, PROXY_USERNAME, PROXY_PASSWORD variables as environment variables.

Create service bus configuration using below sample config

spring:
  cloud:
    function:
      definition: Sampleprocessor
    stream:
      bindings:
        SampleProcessor-in-0:
          destination: input.2
          group: corp-proxy-group
        SampleProcessor-out-0:
          destination: topic-1
    azure:
      servicebus:
        connection-string: Endpoint= <<Azure service bus connection string>>
        transport-type: amqp_web_sockets

Run the application

Code Snippet from ServiceBusClientBuilder.java

    private ProxyOptions getDefaultProxyConfiguration(Configuration configuration) {
        ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE;
The above code sets default authentication to NONE, however, in the downstream, this is never reset if proxy credentials are configured as below.

  private ProxyOptions getProxyOptions(ProxyAuthenticationType authentication, String proxyAddress) {
        String host;
        int port;
        if (HOST_PORT_PATTERN.matcher(proxyAddress.trim()).find()) {
            final String[] hostPort = proxyAddress.split(":");
            host = hostPort[0];
            port = Integer.parseInt(hostPort[1]);
            final Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
            final String username = configuration.get(ProxyOptions.PROXY_USERNAME);
            final String password = configuration.get(ProxyOptions.PROXY_PASSWORD);
            return new ProxyOptions(authentication, proxy, username, password);
        } else {
            com.azure.core.http.ProxyOptions coreProxyOptions = com.azure.core.http.ProxyOptions
                .fromConfiguration(configuration);
            return new ProxyOptions(authentication, new Proxy(coreProxyOptions.getType().toProxyType(),
                coreProxyOptions.getAddress()), coreProxyOptions.getUsername(), coreProxyOptions.getPassword());
        }
    }

Expected behavior
The authentication type is chosen based on the environment varaibles. and not defaulted to NONE.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Windows 10
  • IDE: IntelliJ
  • Library/Libraries: azure-messaging-servicebus 7.4.1
  • Java version: openjdk11
  • App Server/Environment: tomcat
  • Frameworks: Spring Boot

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please provide

  • verbose dependency tree (mvn dependency:tree -Dverbose)

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 21, 2021
@joshfree joshfree added Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. labels Sep 21, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 21, 2021
@joshfree
Copy link
Member

@alzimmermsft could you please follow up with @ram-itzme on Proxy authentication?

@alzimmermsft
Copy link
Member

Re-assigning to @ki1729 as this uses the AMQP style proxy and not the Core style proxy.

@alzimmermsft alzimmermsft assigned ki1729 and unassigned alzimmermsft Sep 21, 2021
@saragluna
Copy link
Member

@ram-itzme I noticed that you pasted configurations of a spring cloud stream binder, were you using the azure-messaging-servicebus directly or the azure-spring-cloud-stream-binder-servicebus-xxx library?

@ram-itzme
Copy link
Author

@saragluna I am using the azure-messaging-servicebus library.

@ram-itzme
Copy link
Author

@saragluna Do you need any additional details from me to look into this issue ?

@saragluna
Copy link
Member

@ram-itzme sorry for the late response; it was our National Day holiday. No more details from my side, but since you're using the SDK instead of the Spring library, I think @ki1729 could help you with this issue.

@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 13, 2022
@ki1729
Copy link
Contributor

ki1729 commented Apr 7, 2022

@ram-itzme Thanks for bringing this up! You are right, Authentication type is never picked up when proxyOptions are loaded from the configuration. As a temproray workaround, you can set the proxyOptions in ServiceBusClientBuilder with the correct authentication type, credentials and address, and that should be picked up correctly.

@ki1729 ki1729 added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Apr 7, 2022
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Apr 7, 2022
@ki1729 ki1729 added Event Hubs and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Apr 7, 2022
@ki1729 ki1729 added this to the [2022] May milestone Apr 7, 2022
@ki1729
Copy link
Contributor

ki1729 commented Apr 7, 2022

Update: Core-amqp changes have been merged and should be part of the May release. The fix for service bus should be either May / June release

@conniey conniey moved this to In Progress in Azure SDK for Event Hubs Jun 29, 2022
@conniey conniey moved this to In Progress in Azure SDK for Service Bus Jun 29, 2022
Repository owner moved this from In Progress to Done in Azure SDK for Event Hubs Oct 31, 2022
Repository owner moved this from In Progress to Done in Azure SDK for Service Bus Oct 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs Service Bus
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants