🚧 Fixed bug

This commit is contained in:
Andreas Dinauer 2026-03-15 13:47:55 +01:00
parent 470516d5da
commit ae668774fa
2 changed files with 8 additions and 6 deletions

View File

@ -16,6 +16,8 @@ import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Link;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,7 +55,7 @@ public class ProxyResource
@Route(path = "/*", order = 1)
public void proxy(@Context RoutingContext context)
{
List<String> requestSegments = List.of(context.request().path().split("/"));
List<String> requestSegments = Arrays.stream(context.request().path().split("/")).filter(item -> !StringUtils.isBlank(item)).toList();
Optional<ProxyRoute> routeOptional = routeService.match(requestSegments);
if (routeOptional.isPresent())
@ -62,7 +64,7 @@ public class ProxyResource
LOG.info("Matched route with target '{}'", route.target());
try
{
HttpResponse<byte[]> response = forward(context.request().method(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments)));
HttpResponse<byte[]> response = forward(context.request().method(), route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments)));
ResponseHandler.success(context, response);
}
catch (Exception e)
@ -78,10 +80,10 @@ public class ProxyResource
}
}
public HttpResponse<byte[]> forward(HttpMethod method, String auth, String forwardRoot, String forwardPath) throws IOException, InterruptedException
public HttpResponse<byte[]> forward(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));
if (auth != null)
if (auth != null && Strings.CI.equals("OIDC", strategy))
{
builder.header("Authorization", String.format("Bearer %s", sessionRepository.get(auth)));
}

View File

@ -1,7 +1,7 @@
routes:
- path: /api
target: http://localhost:8089/api/iam-backend
target: http://backend
strategy: NONE
- path: /
target: http://localhost:8081
target: http://example.com
strategy: NONE