Skip to content

Commit

Permalink
feat(discoveryplugin): copy callback userinfo to auth header, if any
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Feb 21, 2023
1 parent 465bf6d commit 8175dc3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/io/cryostat/discovery/DiscoveryStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@
import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.ext.auth.authentication.UsernamePasswordCredentials;
import io.vertx.ext.web.client.HttpRequest;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

public class DiscoveryStorage extends AbstractPlatformClientVerticle {
Expand Down Expand Up @@ -205,11 +209,17 @@ private Future<Boolean> ping(HttpMethod mtd, URI uri) {
if (Objects.equals(uri, NO_CALLBACK)) {
return Future.succeededFuture(true);
}
return http.request(mtd, uri.getPort(), uri.getHost(), uri.getPath())
.ssl("https".equals(uri.getScheme()))
.timeout(1_000)
.followRedirects(true)
.send()
HttpRequest<Buffer> req =
http.request(mtd, uri.getPort(), uri.getHost(), uri.getPath())
.ssl("https".equals(uri.getScheme()))
.timeout(1_000)
.followRedirects(true);
String userInfo = uri.getUserInfo();
if (StringUtils.isNotBlank(userInfo) && userInfo.contains(":")) {
String[] parts = userInfo.split(":");
req = req.authentication(new UsernamePasswordCredentials(parts[0], parts[1]));
}
return req.send()
.onComplete(
ar -> {
if (ar.failed()) {
Expand Down

0 comments on commit 8175dc3

Please sign in to comment.