diff --git a/src/main/java/dev/dinauer/oidcproxy/ProxyResource.java b/src/main/java/dev/dinauer/oidcproxy/ProxyResource.java index cff7e18..c86e3f5 100644 --- a/src/main/java/dev/dinauer/oidcproxy/ProxyResource.java +++ b/src/main/java/dev/dinauer/oidcproxy/ProxyResource.java @@ -5,6 +5,7 @@ import dev.dinauer.oidcproxy.callback.SessionRepository; import dev.dinauer.oidcproxy.startup.ProxyRoute; import dev.dinauer.oidcproxy.startup.RouteService; import io.quarkus.vertx.web.Route; +import io.vertx.core.MultiMap; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.Cookie; import io.vertx.core.http.HttpMethod; @@ -64,7 +65,7 @@ public class ProxyResource LOG.info("Matched route with target '{}'", route.target()); try { - HttpResponse response = forward(context.request().method(), route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments))); + HttpResponse response = forward(context.request().headers(), context.request().method(), route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments))); ResponseHandler.success(context, response); } catch (Exception e) @@ -80,9 +81,13 @@ public class ProxyResource } } - public HttpResponse forward(HttpMethod method, String strategy, String auth, String forwardRoot, String forwardPath) throws IOException, InterruptedException + public HttpResponse forward(MultiMap headers, HttpMethod method, String strategy, String auth, String forwardRoot, String forwardPath) throws IOException, InterruptedException { HttpRequest.Builder builder = HttpRequest.newBuilder().method(method.name(), HttpRequest.BodyPublishers.noBody()).uri(URI.create(forwardRoot + "/" + forwardPath)); + for (Map.Entry entry : headers.entries()) + { + builder.header(entry.getKey(), entry.getValue()); + } if (auth != null && Strings.CI.equals("OIDC", strategy)) { builder.header("Authorization", String.format("Bearer %s", sessionRepository.get(auth))); diff --git a/src/main/resources/routes.yaml b/src/main/resources/routes.yaml index 23aaf5a..11de261 100644 --- a/src/main/resources/routes.yaml +++ b/src/main/resources/routes.yaml @@ -1,7 +1,7 @@ routes: - path: /api - target: http://backend - strategy: NONE + target: http://localhost:8081 + strategy: OIDC - path: / target: http://example.com strategy: NONE \ No newline at end of file