🚧 Fixed bug
This commit is contained in:
parent
ae668774fa
commit
4d3a40009b
@ -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<byte[]> response = forward(context.request().method(), route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments)));
|
||||
HttpResponse<byte[]> 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<byte[]> forward(HttpMethod method, String strategy, String auth, String forwardRoot, String forwardPath) throws IOException, InterruptedException
|
||||
public HttpResponse<byte[]> 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<String, String> 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)));
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user