🚧 Bugfix with HTTP Client

This commit is contained in:
Andreas Dinauer 2026-04-19 17:04:26 +02:00
parent 0e4fab6995
commit 7216a2f346
5 changed files with 19 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import dev.dinauer.oidcproxy.proxy.ForwardService;
import dev.dinauer.oidcproxy.proxy.ResponseHandler;
import dev.dinauer.oidcproxy.proxy.TimedHttpResponse;
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
import dev.dinauer.oidcproxy.startup.PathConverter;
import dev.dinauer.oidcproxy.startup.ProxyRoute;
@ -89,9 +90,9 @@ public class Resource
accessLog.log(AccessLog.Type.ERROR, context, PathConverter.toPath(requestSegments), route.target(), e.getStatusCode(), e.getTime());
ResponseHandler.error(context, e.getStatusCode());
}
catch (TokenNotFoundException e)
catch (TokenNotFoundException | SessionNotFoundException e)
{
LOG.error("Token not found.", e);
LOG.error("Token / Session not found.", e);
ResponseHandler.error(context, 401);
}
catch (InterruptedException e)

View File

@ -1,6 +1,7 @@
package dev.dinauer.oidcproxy.proxy;
import dev.dinauer.oidcproxy.proxy.exception.ProxyHttpException;
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
import dev.dinauer.oidcproxy.session.SessionCache;
import dev.dinauer.oidcproxy.proxy.header.HeaderFilter;
@ -23,7 +24,7 @@ public class ForwardService
@Inject
HeaderFilter headerFilter;
public TimedHttpResponse<byte[]> send(RoutingContext context, String route, String strategy) throws IOException, InterruptedException, ProxyHttpException, TokenNotFoundException
public TimedHttpResponse<byte[]> send(RoutingContext context, String route, String strategy) throws IOException, InterruptedException, ProxyHttpException, TokenNotFoundException, SessionNotFoundException
{
HttpRequestBuilder builder = HttpRequestBuilder.create();
builder.setUri(route);

View File

@ -0,0 +1,8 @@
package dev.dinauer.oidcproxy.proxy.exception;
public class SessionNotFoundException extends Exception
{
public SessionNotFoundException()
{
}
}

View File

@ -1,5 +1,6 @@
package dev.dinauer.oidcproxy.proxy.header;
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
import dev.dinauer.oidcproxy.proxy.header.strategy.OidcStrategy;
import dev.dinauer.oidcproxy.session.SessionCache;
@ -21,7 +22,7 @@ public class HeaderFilter
@Inject
OidcStrategy oidcStrategy;
public List<Map.Entry<String, String>> filter(HttpServerRequest request, String strategy) throws TokenNotFoundException
public List<Map.Entry<String, String>> filter(HttpServerRequest request, String strategy) throws TokenNotFoundException, SessionNotFoundException
{
List<Map.Entry<String, String>> headers = filterHop2HopHeaders(request.headers().entries());
if ("OIDC".equals(strategy))

View File

@ -1,5 +1,6 @@
package dev.dinauer.oidcproxy.proxy.header.strategy;
import dev.dinauer.oidcproxy.proxy.exception.SessionNotFoundException;
import dev.dinauer.oidcproxy.proxy.exception.TokenNotFoundException;
import dev.dinauer.oidcproxy.session.SessionCache;
import io.quarkus.security.UnauthorizedException;
@ -21,7 +22,7 @@ public class OidcStrategy
@Inject
SessionCache sessionCache;
public List<Map.Entry<String, String>> filter(HttpServerRequest request, List<Map.Entry<String, String>> input) throws TokenNotFoundException
public List<Map.Entry<String, String>> filter(HttpServerRequest request, List<Map.Entry<String, String>> input) throws TokenNotFoundException, SessionNotFoundException
{
if (!hasAuthHeader(input))
{
@ -30,7 +31,7 @@ public class OidcStrategy
return input;
}
private String getAccessToken(HttpServerRequest request) throws TokenNotFoundException
private String getAccessToken(HttpServerRequest request) throws TokenNotFoundException, SessionNotFoundException
{
for (Cookie cookie : request.cookies())
{
@ -40,7 +41,7 @@ public class OidcStrategy
return sessionCache.get(session);
}
}
throw new UnauthorizedException();
throw new SessionNotFoundException();
}
private boolean hasAuthHeader(List<Map.Entry<String, String>> input)