snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

[spring-cloud-config-client] Authentication not added when spring-cloud-config.url defines a endpoint, not a base url #122

Closed snowdrop-bot closed 4 years ago

snowdrop-bot commented 4 years ago

Description When defining a config with a full endpoint url like https://my-domain-url.com/config Quarkus does not succeed in getting configuration when it's protected by Basic Authentication

Expected behavior Successful config retrieve

Actual behavior : 401 http response

Caused by: java.lang.RuntimeException: Got unexpected HTTP response code 401 from https://my-domain-url.com/config/config/my-app-name/dev
        at io.quarkus.spring.cloud.config.client.runtime.DefaultSpringCloudConfigClientGateway.exchange(DefaultSpringCloudConfigClientGateway.java:66)
        at io.quarkus.spring.cloud.config.client.runtime.SpringCloudConfigServerClientConfigSourceProvider.getConfigSources(SpringCloudConfigServerClientConfigSourceProvider.java:37)

Configuration

quarkus.application.name=my-app-name
quarkus.spring-cloud-config.username=user
quarkus.spring-cloud-config.password=pwd
quarkus.spring-cloud-config.fail-fast=true
quarkus.spring-cloud-config.enabled=true
quarkus.spring-cloud-config.url=https://my-domain-url.com/config

Environment :

Step by step : To help resolve the issue , at start-up : 1) DefaultSpringCloudConfigClientGateway#determineBaseUri line 40 : baseUri is the full endpoint "https://my-domain-url.com/config" instead of base uri "https://my-domain-url.com"

2) DefaultSpringCloudConfigClientGateway#setupContext line 83

 authCache.put(HttpHost.create(baseUri), new BasicScheme());

3) org.apache.http.client.protocol.RequestAuthCache#process line 53 Target host is https://my-domain-url.com, port is < 0

line 58 :

 target = new HttpHost(target.getHostName(), route.getTargetHost().getPort(), target.getSchemeName());

At this point target is https://my-domain-url.com:443 line 63 :

 AuthScheme authScheme = authCache.get(target);

Result : AuthScheme is null, and function RequestAuthCache#doPreemptiveAuth is never call to set Authentication Basic


https://github.com/quarkusio/quarkus/issues/10350


$upstream:10350$