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

Eureka Client Basic auth fails with encoded characters #3815

Closed
SledgeHammer01 opened this issue Jun 9, 2020 · 3 comments · Fixed by #4260
Closed

Eureka Client Basic auth fails with encoded characters #3815

SledgeHammer01 opened this issue Jun 9, 2020 · 3 comments · Fixed by #4260

Comments

@SledgeHammer01
Copy link

This works/worked in 2.2.2:

eureka.client.service-url.defaultZone=https://eureka:xxx@aaa.xxx.com:8761/eureka/

In 2.2.3, I get:

reactor.core.Exceptions$ReactiveException: java.net.UnknownHostException: eureka:xxxx@xxxx.xxxx.com: invalid IPv6 address
	at reactor.core.Exceptions.propagate(Exceptions.java:393) ~[reactor-core-3.3.5.RELEASE.jar:3.3.5.RELEASE]
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97) ~[reactor-core-3.3.5.RELEASE.jar:3.3.5.RELEASE]
	at reactor.core.publisher.Mono.block(Mono.java:1678) ~[reactor-core-3.3.5.RELEASE.jar:3.3.5.RELEASE]
	at org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient.getApplicationsInternal(WebClientEurekaHttpClient.java:139) ~[spring-cloud-netflix-eureka-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient.getApplications(WebClientEurekaHttpClient.java:124) ~[spring-cloud-netflix-eureka-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.netflix.eureka.config.EurekaConfigServerBootstrapConfiguration.lambda$eurekaConfigServerInstanceProvider$0(EurekaConfigServerBootstrapConfiguration.java:112) ~[spring-cloud-netflix-eureka-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.config.client.ConfigServerInstanceProvider.getConfigServerInstances(ConfigServerInstanceProvider.java:50) ~[spring-cloud-config-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration$HeartbeatListener.refresh(DiscoveryClientConfigServiceBootstrapConfiguration.java:120) ~[spring-cloud-config-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration$HeartbeatListener.startup(DiscoveryClientConfigServiceBootstrapConfiguration.java:106) ~[spring-cloud-config-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.config.client.DiscoveryClientConfigServiceBootstrapConfiguration$HeartbeatListener.onApplicationEvent(DiscoveryClientConfigServiceBootstrapConfiguration.java:98) ~[spring-cloud-config-client-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212) ~[spring-cloud-context-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117) ~[spring-cloud-context-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74) ~[spring-cloud-context-2.2.3.RELEASE.jar:2.2.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
	at org.firstamerican.dtms.test.DtmsTestApplication.main(DtmsTestApplication.java:26) ~[main/:na]
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99) ~[reactor-core-3.3.5.RELEASE.jar:3.3.5.RELEASE]
		... 32 common frames omitted
Caused by: java.net.UnknownHostException: eureka:xxxx@xxxx.xxxx.com: invalid IPv6 address
	at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1341) ~[na:na]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
	|_ checkpoint ? Request to GET https://eureka:xxxx@xxxx.xxxx.com:8761/eureka/apps/?regions=us-east-1 [DefaultWebClient]
Stack trace:
		at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1341) ~[na:na]
		at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298) ~[na:na]
		at java.base/java.net.InetAddress.getByName(InetAddress.java:1248) ~[na:na]
		at io.netty.util.internal.SocketUtils$8.run(SocketUtils.java:156) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.internal.SocketUtils$8.run(SocketUtils.java:153) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
		at io.netty.util.internal.SocketUtils.addressByName(SocketUtils.java:153) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.DefaultNameResolver.doResolve(DefaultNameResolver.java:41) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:61) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.SimpleNameResolver.resolve(SimpleNameResolver.java:53) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:55) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.InetSocketAddressResolver.doResolve(InetSocketAddressResolver.java:31) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.resolver.AbstractAddressResolver.resolve(AbstractAddressResolver.java:106) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.bootstrap.Bootstrap.doResolveAndConnect0(Bootstrap.java:206) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.bootstrap.Bootstrap.access$000(Bootstrap.java:46) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.bootstrap.Bootstrap$1.operationComplete(Bootstrap.java:180) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.bootstrap.Bootstrap$1.operationComplete(Bootstrap.java:166) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:551) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.AbstractChannel$AbstractUnsafe.safeSetSuccess(AbstractChannel.java:984) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:504) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:417) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:474) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-all-4.1.49.Final.jar:4.1.49.Final]
		at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
@SledgeHammer01
Copy link
Author

SledgeHammer01 commented Jun 9, 2020

Issue is in WebClientTransportClientFactory.java WebClient.Builder of:

	url = serviceUrl.replace(credentials[0] + ":" + credentials[1] + "@",
					"");

By this time, String[] credentials = serviceURI.getUserInfo().split(":") has URL decoded the username and password already, so MyPassword%40 is MyPassword@ in credentials[1] and fails on the string replace since the url contains MyPassword%40.

@spencergibb spencergibb changed the title Eureka Client Basic auth no longer working in 2.2.3 Eureka Client Basic auth fails with encoded @ symbol Jun 9, 2020
@SledgeHammer01
Copy link
Author

@spencergibb it will actually fail with any url encoded character, not just the @ sign :)

@spencergibb spencergibb changed the title Eureka Client Basic auth fails with encoded @ symbol Eureka Client Basic auth fails with encoded characters Jun 10, 2020
@iPankhu
Copy link

iPankhu commented Oct 1, 2021

I am picking this bug and will work on it.

ZIRAKrezovic added a commit to ZIRAKrezovic/spring-cloud-netflix that referenced this issue Feb 19, 2024
ZIRAKrezovic added a commit to ZIRAKrezovic/spring-cloud-netflix that referenced this issue Mar 26, 2024
ZIRAKrezovic added a commit to ZIRAKrezovic/spring-cloud-netflix that referenced this issue Mar 27, 2024
@OlgaMaciaszek OlgaMaciaszek added this to the 4.1.2 milestone Apr 2, 2024
ZIRAKrezovic added a commit to ZIRAKrezovic/spring-cloud-netflix that referenced this issue Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants